Last active
December 12, 2017 10:37
-
-
Save Youka/4b6cb42fd58a6f979974 to your computer and use it in GitHub Desktop.
Get browser scrollbar width/height
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
| function getScrollbarSize() { | |
| var hiddenScroll = jQuery('<div />', { | |
| css: { | |
| visibility: 'hidden', | |
| width: 100, | |
| 'overflow-y': 'scroll' | |
| } | |
| }).appendTo('body'), | |
| hiddenScrollContentWidth = jQuery("<div />").css('width', '100%').appendTo(hiddenScroll).outerWidth(); | |
| hiddenScroll.remove(); | |
| return 100 - hiddenScrollContentWidth; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment