Code Monkey

04 Feb

Forcing Vertical Scroll Bars

In developing centered pages I’ve noticed that if you go from one page to another and one page is longer then the screen and the other is shorter, the page jumps around and doesn’t remain centered.  Why?  Because most browsers (IE being the exception) hide scroll bars if they aren’t needed.

 So how can you fix this?  Easy,

in your style sheet just add this:

 html{height: 100%; margin-bottom: 1px;}

 so the user will always see the scroll bar and it only scrolls down a tad.  Much better then adding hundreds of br’s with spaces now isn’t it.

Leave a Reply

© 2009 Code Monkey | Entries (RSS) and Comments (RSS)

Global Positioning System Gazettewordpress logo