# Web pages jumping when scrollbar appears



## YellowMonkeyMan (Feb 9, 2010)

Hi there

I have another question for you lovely people (and I hope flattery will get me everywhere).

I am currently building a website and my one remaining niggle is as follows:

My page div is currently centrally aligned within my site, however when the page goes from a page in full view in the browser to a different page where the scroll bar is required, there is a small 'jump' in the page to compensate for the presence of the scroll bar. Is there any way I can keep my page central without inputting a precise number of pixels (or whatever) that may cause the page view to be dodgy for those with lower screen resolutions? And crucially not to jump with the scroll bar.

It's a relatively minor niggle, but if anyone has any suggestions I'll be all ears!

Thanks in advance.


----------



## tomdkat (May 6, 2006)

I haven't seen any of your other posts so I know nothing about how your site is designed or about the page layout but you really can't do much to control how the main containing DIV is positioned when the scroll bar is present or not. You can center the DIV like this:

```
CSS:
#main-container { margin-left: auto; margin-right: auto; width: (some width specified); }

HTML:
....
<div id="main-container">
(content)
</div>
```
Even that will cause the 'main container' DIV to shift to the left a bit when the scroll bar is displayed and shift to the right when it's not.

Do you have a link to the site you can post?

Peace...


----------



## YellowMonkeyMan (Feb 9, 2010)

Hi, cheers for that.

The site is http://www.transym.com/newsite/index.htm

What about keeping the scroll bar permanently in place then? Even when it's not strictly required.


----------



## YellowMonkeyMan (Feb 9, 2010)

Never mind, managed to fix it now by having a permanent scrollbar. If anyone else reads this, here's the code to go into your CSS.

html {overflow-y: scroll;}


----------



## tomdkat (May 6, 2006)

Yep, forcing a scrollbar is another way of dealing with that behavior. 

Peace...


----------

