Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Sep 2006
    Posts
    40
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question CSS Centering for Firefox and IE

    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

  • #2
    New Coder
    Join Date
    Sep 2006
    Location
    Netherlands
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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;.
    As a rule, I never touch anything more sophisticated and delicate than myself.

  • #3
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,478
    Thanks
    6
    Thanked 981 Times in 954 Posts
    Quote Originally Posted by Desdinova View Post
    [...] 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.

  • #4
    New Coder
    Join Date
    Sep 2006
    Location
    Netherlands
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by VIPStephan View Post
    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.
    As a rule, I never touch anything more sophisticated and delicate than myself.

  • #5
    New Coder
    Join Date
    Sep 2006
    Posts
    40
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Smile Thank You!

    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!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •