Design Directory Discussion Forum Design Job Board Add Your Site Post a Message Post a Job / Gig

HomeDevelopers → Center a div on IE

Hello,

I'm trying to center a div, which I was able to do with a wrap ID margin: auto; and it works lovely in Firefox and Opera, but not on IE. How can I get this work centered in IE?

Thanks.
Visit My Website | -Adriana www.breathewords.com www.scene360.com
? this may help
? http://www.adobe.com/devnet/dreamweaver/articles/css_concepts_05.html

Thanks, going to read it. I've been learning more CSS, I hope you are happy! Haha :) I'm getting a better understanding of the divs, just need to practice more. I doubt I'll become an ace programmer; but I always have room for improvement, and trying to improve. Thanks for the tips.
Visit My Website | -Adriana www.breathewords.com www.scene360.com
Just think...with IE7 we may get to say goodbye to the center CSS hack.

Huzzah!
Visit My Website | www.teamunited.com
Add two new styles to your CSS sheet: The first makes the div centralised in IE; other browsers listen to margin:auto
body {text-align:center;}

Now because all browsers think that every sub-element of body should be centrally aligned, we hack the containing div with: (substitute the class declaration with your containing div class or id)

.container {text-align:left;}

You always seem to ask the nice easy ones whilst I'm on holiday Adriana, Sitges nr Barcelona this time! Hope this helps anyway!
? .container {text-align:left;}

thanks gavin for your helping code
and Adariana for asking such a good code issue that I was looking for too

regrads,
Anand
Visit My Website | www.creativevigor.com | www.nestcraft.com
Oh, so you are living la vida grande in Spain. Hmmm... why am I not on vacation too. I hope you are having a good time Gavin. Are you visiting Barcelona? Beautiful city.

Thanks for the CSS tip. Clever. This worked.
Visit My Website | -Adriana www.breathewords.com www.scene360.com
css centre a div

If your div is relative

margin-left:auto;
margin-right:auto;

Is this what you need ?
creative-web-de

it totaly correct... this is the best way to center a div