Forum Moderators: not2easy

Message Too Old, No Replies

Scrollbar throws centering off

         

Graeme2006

5:07 pm on Aug 3, 2006 (gmt 0)

10+ Year Member



Hi,
I have some CSS that centers the entire page.
body{
width: 760px;
margin: 0 auto;
}

The problem is that whenever a page goes beyond the browsers viewing area, the scrollbar comes out and this shifts the page slightly to the left. It looks akward when switching between pages, some of which are short, and some longer. Any idea how to stop this behaviour? (by the way, the problem does NOT occur in IE).

Thanks,
Graeme

Robin_reala

9:15 pm on Aug 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Some while ago I noticed this, but decided tha normal users couldn't care less and forgot about it :)

If you're positive you want to stop then shift then you can force scrollbars on all the time by adding the folowing to your CSS:

html { overflow-y: scroll; }

Graeme2006

4:40 pm on Aug 4, 2006 (gmt 0)

10+ Year Member



I thought of that, but there must be a way around it.

Also, the way my page is set up, it looks really bad when navigating

Robin_reala

5:22 pm on Aug 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A way around what? In IE the scrollbars are on permenantly - that's why you don't see the shift. In Firefox they're not (btw this is a deliberate design decision for better or worse) but you can force it to be like IE with the code I posted above. Apart from that what else can you do?

Graeme2006

4:02 pm on Aug 8, 2006 (gmt 0)

10+ Year Member



ya thanks, that's probably what I'll just end up doing (and I didn't notice IE had it on permanently)