View Full Version : Vertically align a div in the page

02-06-2007, 02:46 AM
Hi, I'm trying to get a div..

height: 100%;
text-align: center;

width: 700px;
height: 400px;

..to vertically center within the page.
in other words, I need it dead center on the page!

is this possible?

Thanks in advance

02-06-2007, 02:51 AM
Try to add:

margin: 0px auto 0px auto;

to the css of the div

02-06-2007, 03:38 AM
Hello tylerjca,
Sman's code will center your site horizontally (it can be shortened to margin: 0 auto; usually too).

To center if vertically is a little different.

#layerwhatever {
position: relative;
top: 50%;
margin-top: -???px; /* replace the ??? with half the height of the div, ex: 200px high would be 100px */
margin: 0 auto;

02-06-2007, 04:06 AM
this will work as well. pretty much the same thing but I had to post because I wrote a big long one and it was taking forever to upload so I lost it. Meantime somebody else answered your question :)

width: 700px;
height: 400px;
margin-top: -200px;
top: 50%;

02-06-2007, 05:26 PM
Try this method; it's the best I've seen so far:


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum