View Full Version : DIV won't center with margin:auto
02-22-2011, 09:45 AM
Hey, I'm trying to center the floated .main DIV in this page, but can't get it to work. Confused.
Any help appreciated.
02-22-2011, 09:51 AM
I don't see any CSS in your page.
02-22-2011, 10:04 AM
Sorry, I was uploading it. The CSS is there now.
02-22-2011, 10:23 AM
Validator (http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fwww.innovationsbydesigns.ca%2F) is your friend! You have multiple DOCTYPEs in your markup.
02-22-2011, 10:42 AM
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?
02-22-2011, 10:46 AM
Now, that's how a float work. Why do you need that float (on .main) there?
02-22-2011, 10:55 AM
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.
02-22-2011, 11:03 AM
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 (http://www.quirksmode.org/css/clearing.html).
02-22-2011, 12:07 PM
Cheers. I put a clear float at the end of the .main div, and that sorted it.
Thanks a lot.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.