SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Div Element Won't Center

    I'm trying to center a div element and I can't seem to figure out why it isn't centering. I know there is something conflicting, but I can't seem to figure out just what it is. Any help would be greatly appreciated. Thanks!

    CSS in question:
    Code CSS:
    .aligncenter, div.aligncenter, .post p div.aligncenter { display: block; margin-left: auto; margin-right: auto; }

    HTML in question:
    Code HTML4Strict:
    <p><div class="aligncenter"><img src="http://justincox.com/wordpress/wp-content/uploads/2009/12/azumi.png" alt="Azumi" border="0" width="500" height="326" /></div></p>

    Full source: http://justincox.com/2009/year-in-movies-December/

  2. #2
    Ripe Tomatos silver trophybronze trophy Rayzur's Avatar
    Join Date
    Jun 2007
    Location
    Texas
    Posts
    4,174
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    Auto margins only work when a width has been set.

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow, that was fast. Thank you. Adding width: inherit; fixed the issue. Knew it was something simple. Thanks again.

  4. #4
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,726
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    The value "inherit" isn't supported ihn IE7< except for a few properties

    Setting an actual width (aka 500px or whatever) would work better.
    Always looking for web design/development work.
    http://www.CodeFundamentals.com


Bookmarks

Posting Permissions

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