...

View Full Version : align: center; ?



YaymeQ
02-20-2008, 08:04 AM
Okay ... that does absolutely nothing, or so I've noticed in my code.
How do you align the contents of a div to the center? Text-align doesn't work with images ... so how can we do this?

Thanks for any help
~Yaymeq

rangana
02-20-2008, 08:18 AM
Just have margin: auto; in it, and if nothing works, could you wrap your codes or better post a link

See if it helps :D

Andrew Johnson
02-20-2008, 12:27 PM
Maybe this will help:

HTML


<div class="outer">
<div class="inner">
center me!
</div>
</div>


CSS


div.outer
{
text-align:center
}

div.inner
{
margin:auto; /* WITHOUT THIS LINE THE INNER DIV WON'T BE CENTERED */
width:90&#37;
}

ahallicks
02-20-2008, 02:45 PM
Text-align works with images as long as they are block-level and don't inherit any floats

Apostropartheid
02-20-2008, 07:34 PM
Text-align works with images as long as they aren't block-level and don't inherit any floats
I presume you're doing something silly with your images if it's not working. Code, s'il vous plaît?

ahallicks
02-23-2008, 02:55 PM
You can't center an inline element

_Aerospace_Eng_
02-23-2008, 03:49 PM
You can't center an inline element

Yes you can, using text-align:center; on the parent element. It will center the inline element like an image horizontally. The correct way to center a block level element is by using margin:auto; and a set width.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum