View Full Version : Vertically align a div in the page
02-06-2007, 03:46 AM
Hi, I'm trying to get a div..
..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, 03:51 AM
Try to add:
margin: 0px auto 0px auto;
to the css of the div
02-06-2007, 04:38 AM
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.
margin-top: -???px; /* replace the ??? with half the height of the div, ex: 200px high would be 100px */
margin: 0 auto;
02-06-2007, 05: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 :)
02-06-2007, 06:26 PM
Try this method; it's the best I've seen so far:
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.