Last active
December 23, 2015 04:59
-
-
Save WebReflection/6583649 to your computer and use it in GitHub Desktop.
Mobile VS Desktop, the scroll bar might or might not appear plus it's different in most browsers. Windows 8 has 17 pixels scrollbar, Mac has usually 15 pixels only but not a single smart phone has more than 0 pixels. Refined after reading [David Walsh good old post](http://davidwalsh.name/detect-scrollbar-width), feel free to use this *constant*…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var SCROLLBAR_SIZE = SCROLLBAR_SIZE || function(d){ | |
| var | |
| e = d.documentElement, | |
| p = d.createElement('p'), | |
| r | |
| ; | |
| p.style.cssText = [ | |
| ';position:absolute', | |
| ';margin:0', | |
| ';padding:0', | |
| ';display:block', | |
| ';overflow:scroll', | |
| ';width:50px', | |
| // actually needed to avoid clientWidth 0 | |
| ';line-height:50px', | |
| ';font-size:50px' | |
| ].join(' !important'); | |
| p.innerHTML = '0'; | |
| e.insertBefore(p, e.lastChild); | |
| r = p.offsetWidth - p.clientWidth; | |
| e.removeChild(p); | |
| return r; | |
| }(document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment