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 9 of 9
  1. #1
    New Coder
    Join Date
    Dec 2010
    Posts
    66
    Thanks
    16
    Thanked 0 Times in 0 Posts

    DIV won't center with margin:auto

    Hey, I'm trying to center the floated .main DIV in this page, but can't get it to work. Confused.

    Any help appreciated.

    http://www.innovationsbydesigns.ca

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    I don't see any CSS in your page.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Dec 2010
    Posts
    66
    Thanks
    16
    Thanked 0 Times in 0 Posts
    Sorry, I was uploading it. The CSS is there now.
    Last edited by JumpJump; 02-22-2011 at 10:25 AM.

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Validator is your friend! You have multiple DOCTYPEs in your markup.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    New Coder
    Join Date
    Dec 2010
    Posts
    66
    Thanks
    16
    Thanked 0 Times in 0 Posts
    Thanks. Fixed. That's not the problem with the float though (and only happened because I'm working locally and uploaded in a hurry just to get some feedback on this problem). I'm trying to center the .main DIV, any suggestions?

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Now, that's how a float work. Why do you need that float (on .main) there?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #7
    New Coder
    Join Date
    Dec 2010
    Posts
    66
    Thanks
    16
    Thanked 0 Times in 0 Posts
    Floating the .main div left seems to be the only way I can get the div to actually contain its contents. Without it, the div is centered but is only about 20px in height. I have to specify a height then which isn't ideal.

    I want to float the contents of the .main div and have the div extend vertically to fit these contents.

  • #8
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Without it, the div is centered but is only about 20px in height. I have to specify a height then which isn't ideal.
    Let's face it and try to find an "elegant" fix for that issue then. From your description, it seems like you need to clear some floats.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    JumpJump (02-22-2011)

  • #9
    New Coder
    Join Date
    Dec 2010
    Posts
    66
    Thanks
    16
    Thanked 0 Times in 0 Posts
    Cheers. I put a clear float at the end of the .main div, and that sorted it.

    Thanks a lot.


  •  

    Posting Permissions

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