...

View Full Version : CSS Centering for Firefox and IE



mb89
09-19-2006, 02:24 PM
Hi,

I'm pretty new to CSS and am trying to get my page to center. It has worked perfectly in IE but in Firefox it refuses to move over and it also won't fill the 100% space of the screen. See http://mattyboy.campinnovations.com.au for details. If anyone could be of help that would be great!

mb89

Desdinova
09-19-2006, 02:41 PM
give the element that needs to be centered the margin-left: auto; and margin-right: auto;
or shortly margin: 0px auto;

make sure it doesn't have a float, because floats don't center.


[edit]
and of course, the element that contains the element that needs to be aligned, should have style text-align: center;.

VIPStephan
09-19-2006, 03:03 PM
[...] and of course, the element that contains the element that needs to be aligned, should have style text-align: center;.
I can't agree with that. It doesn't matter how the text (or inline elements) are aligned within the centered element.
You were right with the margin: 0 auto; thing - which by the way only works with block level elements (like div, form, table, paragraph...) and in IE only if it's in standards mode.

In a nutshell: margin: 0 auto; for block elements, text-align: center; for inline elements (e.g. span, a, img... and plain text within a block element, of course).

And to clarify it for mb89: your div.master needs margin: 0 auto; in order to be centered.

Desdinova
09-19-2006, 03:07 PM
I can't agree with that. It doesn't matter how the text (or inline elements) are aligned within the centered element.
You were right with the margin: 0 auto; thing - which by the way only works with block level elements (like div, form, table, paragraph...) and in IE only if it's in standards mode.

In a nutshell: margin: 0 auto; for block elements, text-align: center; for inline elements (e.g. span, a, img... and plain text within a block element, of course).

And to clarify it for mb89: your div.master needs margin: 0 auto; in order to be centered.

that I didn't know. Usually I set both and that turns out pretty well. I'll take an extra look at it next time.

mb89
09-20-2006, 03:30 PM
Oi .... thanks so much! It works now, it took me so long just to come up with that CSS code and you guys make it look so easy.

Thank You
Vielen Dank!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum