...

View Full Version : vertical and horizontal centered divs



garabildi
09-01-2011, 12:12 PM
I'm looking to center divs on the x and y axis. I've followed the advice here (http://www.pmob.co.uk/pob/hoz-vert-center.htm) but the problem is there is a difference in layout between the example and what I require.

I need to center this:


<body>
<div id="main">
<div id="left"><img src="logo.gif" />
</div>
<div id="right"><p>text</p>
</div>
</div>
</body>


unlike the the link which centers everything, I want to center the #main and the image in #left on the left and the text in #right to appear on the right. I've messed around with floats but that didn't help.

garabildi
09-01-2011, 12:47 PM
Got it :)

#main{
position:absolute;
height:500px;
width:700px;
background:blue;
left:50%;
top:50%;
margin-left:-350px;
margin-top:-250px;
}

#left{float:left;}

#right{float: right;}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum