Skip to content

Instantly share code, notes, and snippets.

@yukulele yukulele/scroobar-width.js
Last active Aug 29, 2015

Embed
What would you like to do?
scrollbar width
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
You can’t perform that action at this time.