...

View Full Version : DIV won't center with margin:auto



JumpJump
02-22-2011, 08: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.

http://www.innovationsbydesigns.ca

abduraooft
02-22-2011, 08:51 AM
I don't see any CSS in your page.

JumpJump
02-22-2011, 09:04 AM
Sorry, I was uploading it. The CSS is there now.

abduraooft
02-22-2011, 09: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.

JumpJump
02-22-2011, 09: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?

abduraooft
02-22-2011, 09:46 AM
Now, that's how a float work. Why do you need that float (on .main) there?

JumpJump
02-22-2011, 09: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.

abduraooft
02-22-2011, 10: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).

JumpJump
02-22-2011, 11:07 AM
Cheers. I put a clear float at the end of the .main div, and that sorted it.

Thanks a lot.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum