Last active
August 29, 2015 13:57
-
-
Save yukulele/9911462 to your computer and use it in GitHub Desktop.
scrollbar width
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 scrollBarWidth = (function(){ | |
var html = document.documentElement; | |
var outer = document.createElement("div"); | |
var inner = document.createElement("div"); | |
outer.style.visibility = "hidden"; | |
outer.style.width = "100px"; | |
outer.style.overflow = "scroll"; | |
outer.appendChild(inner); | |
html.appendChild(outer); | |
var outerWidth = outer.offsetWidth; | |
var innerWidth = inner.offsetWidth; | |
html.removeChild(outer); | |
return outerWidth - innerWidth; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment