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 7 of 7
  1. #1
    Regular Coder YaymeQ's Avatar
    Join Date
    Feb 2008
    Location
    virginia
    Posts
    140
    Thanks
    14
    Thanked 0 Times in 0 Posts

    align: center; ?

    Okay ... that does absolutely nothing, or so I've noticed in my code.
    How do you align the contents of a div to the center? Text-align doesn't work with images ... so how can we do this?

    Thanks for any help
    ~Yaymeq
    Where is the "any" key??!

  • #2
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Just have margin: auto; in it, and if nothing works, could you wrap your codes or better post a link

    See if it helps

  • #3
    Banned
    Join Date
    Feb 2008
    Location
    Winnipeg, Canada
    Posts
    396
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Maybe this will help:

    HTML
    Code:
    <div class="outer">
       <div class="inner">
          center me!
       </div>
    </div>
    CSS
    Code:
    div.outer
    {
       text-align:center
    }
    
    div.inner
    {
       margin:auto; /* WITHOUT THIS LINE THE INNER DIV WON'T BE CENTERED */
       width:90&#37;
    }

  • #4
    Senior Coder ahallicks's Avatar
    Join Date
    May 2006
    Location
    Lancaster, UK
    Posts
    1,134
    Thanks
    1
    Thanked 57 Times in 55 Posts
    Text-align works with images as long as they are block-level and don't inherit any floats
    "write it for FireFox then hack it for IE."
    Quote Originally Posted by Mhtml View Post
    Domains are like women - all the good ones are taken unless you want one from some foreign country.
    Reputation is your friend

    Development & SEO Tools

  • #5
    The Apostate Apostropartheid's Avatar
    Join Date
    Oct 2007
    Posts
    3,215
    Thanks
    16
    Thanked 265 Times in 263 Posts
    Quote Originally Posted by ahallicks View Post
    Text-align works with images as long as they aren't block-level and don't inherit any floats
    I presume you're doing something silly with your images if it's not working. Code, s'il vous plaît?

  • #6
    Senior Coder ahallicks's Avatar
    Join Date
    May 2006
    Location
    Lancaster, UK
    Posts
    1,134
    Thanks
    1
    Thanked 57 Times in 55 Posts
    You can't center an inline element
    "write it for FireFox then hack it for IE."
    Quote Originally Posted by Mhtml View Post
    Domains are like women - all the good ones are taken unless you want one from some foreign country.
    Reputation is your friend

    Development & SEO Tools

  • #7
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Quote Originally Posted by ahallicks View Post
    You can't center an inline element
    Yes you can, using text-align:center; on the parent element. It will center the inline element like an image horizontally. The correct way to center a block level element is by using margin:auto; and a set width.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

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