centering in firefox

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I want to center an element, but also start it at top of page with no

I have 2 elements, second a child of first

1. style="position:absolute;top:0;"

2. style = "width:1000px;
display: block;
margin-left: auto;
margin-right: auto;"

This works in ie but not firefox

Re: centering in firefox

In article

Quoted text here. Click to load it

So which element do you want to centre, one or both?


Re: centering in firefox

Quoted text here. Click to load it

Only because IE is wrong. Add left: 0; right: 0 and you will get the
effect you want in Firefox.

See CSS 2.1 10.3.7

Quite hard to read, but the main point there is that you will only get
centering of absolutely positioned things if left, width and right are
all non-auto. You set width but not left or right.

But it may be better to get rid of the gap with body { margin-top: 0 }
instead and leave the block statically positioned.

Site Timeline