Last active
April 4, 2019 15:23
-
-
Save Venegrad/19cc78cc554ff1eeedc0deb1a2efdb2e to your computer and use it in GitHub Desktop.
Get ScrollBarWidth jquery
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 getScrollBarWidth(bool) { | |
if(bool == true) { | |
var $outer = $('<div>').css({visibility: 'hidden', width: 100, overflow: 'scroll'}).appendTo('body'), | |
widthWithScroll = $('<div>').css({width: '100%'}).appendTo($outer).outerWidth(); | |
$outer.remove(); | |
return 100 - widthWithScroll; | |
} else { | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment