Force Vertical Scroll Bars with CSS3

Here’s a quick and simple one!

The Problem: When using centered layouts, if you get to a page which doesn’t have enough content to cause the page to scroll, the layout will ‘jump’ slightly to the side compared to pages which have a scroll bar.

The Solution: For once, IE seems to do the right thing here and always forces a scroll bar. So we can use a new CSS3 property called “overflow-y”. This works in the latest versions of all the main browsers: Chrome, Safari, Firefox and Opera.

1
html {overflow-y: scroll;}

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">