Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4

Thread: CSS center

  1. #1
    Senior Member diciccod's Avatar
    Join Date
    Jan 2004
    Location
    East Lansing, MI... Michigan State!
    Posts
    121
    Member #
    4678
    just a quick question on basic css.

    at http://reagan.dominicdicicco.com i would like the text box below the image to be centered. It is in the same ID as the image which has text-align: center; in it. The image and text both center in IE but only the image centers in firefox. It would be appreciated if anyone could give some insight on this. Thanks!

    EDIT: also when i take away the class from the <p> tag it centers in firefox. I don't understand this because the class has nothing in it about alignment.

  2.  

  3. #2
    Senior Member Trico's Avatar
    Join Date
    Feb 2004
    Location
    Nottingham, UK
    Posts
    894
    Member #
    5081
    Code:
    p.textbox {
    background-color: #FF9;
    width: 200px;
    border-color: #630;
    border-style: solid;
    margin: 0 auto; /* Add this line */
    }

  4. #3
    Senior Member diciccod's Avatar
    Join Date
    Jan 2004
    Location
    East Lansing, MI... Michigan State!
    Posts
    121
    Member #
    4678
    Awesome. Worked perfect.

    But why is that, why does firefox require "margin: 0 auto;" and why does that allow it to be centered?

  5. #4
    Senior Member Trico's Avatar
    Join Date
    Feb 2004
    Location
    Nottingham, UK
    Posts
    894
    Member #
    5081
    Well as the attribute name implies, text-align is for aligning text within other block elements not the actual block element itself. The reason this still occurs is down to the poor interpretation of CSS on behalf of browser makers I.E. Microsoft/Netscape etc.

    Margin: 0 auto; applys both a top and bottom margin of 0 and an equal value for both the left and right sides... flushing everything into the centre of the page.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:20 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com