Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent scroll-bar from adding-up to the Width of page on Chrome

People also ask

How do I change the scrollbar width in Chrome?

Once you have installed this extension on your Chrome browser, click on its extension icon present on the top right part of the Chrome browser. This will open the Options or Settings page of this Chrome extension. On the Options page, you will see a slider for Scrollbar Size.

How do I fix the scroll bar on Google Chrome?

Open a Chrome window. In the address bar, enter "chrome://flags," and navigate to that page. Scroll down to Overlay Scrollbars, and set the field to "Disabled." Restart your browser window, and your scrollbars should work again in PicMonkey.


DISCLAIMER: overlay has been deprecated.
You can still use this if you absolutely have to, but try not to.

This only works on WebKit browsers, but I like it a lot. Will behave like auto on other browsers.

.yourContent{
   overflow-y: overlay;
}

This will make the scrollbar appear only as an overlay, thus not affecting the width of your element!


All you need to do is add:

html {
    overflow-y: scroll;
}

In your css file as this will have the scroller whether it is needed or not though you just won't be able to scroll

This means that the viewport will have the same width for both


Probably

html {
    width: 100vw;
}

is just what you want.


You can get the scrollbar size and then apply a margin to the container.

Something like this:

var checkScrollBars = function(){
    var b = $('body');
    var normalw = 0;
    var scrollw = 0;
    if(b.prop('scrollHeight')>b.height()){
        normalw = window.innerWidth;
        scrollw = normalw - b.width();
        $('#container').css({marginRight:'-'+scrollw+'px'});
    }
}

CSS for remove the h-scrollbar:

body{
    overflow-x:hidden;
}

Try to take a look at this: http://jsfiddle.net/NQAzt/


Webkit browsers like Safari and Chrome subtract the scroll bar width from the visible page width when calculating width: 100% or 100vw. More at DM Rutherford's Scrolling and Page Width.

Try using overflow-y: overlay instead.