Thursday, August 26, 2010

The Best Way to Prevent Horizontal Jumping

If you have a horizontally centered web site with multiple pages of different heights, sometimes it will seem to jump to the left or right when you change pages, because the scroll bar is appearing and disappearing.

The best way to prevent this is to force the scroll bar to appear on all pages, with this code in your CSS:

html {
overflow-y: scroll;
}

Thanks to CSS-Tricks for the code!

0 comments: