3

I am using a fixed width layout for a website (1000px), with the layout being centered in the screen by auto margins. However, I find that on some pages on the website, the layout is positioned slightly different than other pages for some reason. This is surprising to me, because I use Django and serve the same base template and stylesheet to each page, so I would expect them to look the same.

For example, take a look at http://crh.vkuzo.com/. If you load the "home" and "suggest" pages, the layout stays exactly the same. However, if you load the "about" page, you can see the layout move slightly to the left.

What is causing this slight movement, and how can I get rid of it?

P.S. here is the relevant CSS for the container div (at least what I think is relevant):

#wholepage {
    width:1000px;
    clear:left;
    margin-top:10px;
    margin-left:auto;
    margin-right:auto;
    margin-bottom:10px;
}
vasek1
  • 13,541
  • 11
  • 32
  • 36
  • possible duplicate of [How to prevent scrollbar from repositioning web page?](http://stackoverflow.com/questions/1417934/how-to-prevent-scrollbar-from-repositioning-web-page) – Quentin Jan 23 '12 at 16:45
  • I believe the layout change you're seeing is due to a scrollbar being shown on the about page. You should be able to get around this by always showing the scrollbar: try "overflow-y: scroll" – dinjas Jan 23 '12 at 16:46
  • @Quentin yep, didn't realize that it was the scrollbar and had a "duh" moment:D – vasek1 Jan 23 '12 at 16:58

3 Answers3

8

It is the browser's scroll bar. See: How to prevent scrollbar from repositioning web page?

Community
  • 1
  • 1
Logan Serman
  • 29,447
  • 27
  • 102
  • 141
5

Add this style:

body {
    ...
    overflow-y: scroll;
}

For centered pages, you want the scroll-bar to be always visible (even when it's not needed). That way the page won't shift horizontally depending on whether the scroll-bar is visible or not.

Šime Vidas
  • 182,163
  • 62
  • 281
  • 385
1

The scroll bar is adjusting the layout. When the scroll bar appears on the browser window, it minimizes the width by a certain amount of pixels (the width of the scroll bar itself).