Vertically centre a div?

Associate
Joined
20 Sep 2003
Posts
2,374
Location
Scotland
Just making a very simple placement page. Would like to vertically centre the page using CSS, how can this be achieved?

Page is here

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Maintenance Page</title>
<style type="text/css">
body 	{

	background-color: #FFFFFF;
	color: #D50037;
	text-align: center;
}

#container 	{
	width: 100%;
	height: 520px;
	margin: auto;
}

.text {
	font-family: Interstate,Trebuchet MS,Arial,Helvetica,sans-serif;
        font-size: 10pt;
        font-weight: bold;
}
</style>

</head>
<body>
<div id="container">
<p align="center"><img src="release_update.png" align="center" alt="TalentSource is currently down due to scheduled maintenance." /></p>

<br />
<br />

<p class="text">This page is currently down due to scheduled maintenance.</p>
<p class="text">Please try again in 15 minutes.</p>

</div> <!--container closing div-->
</body>
</html>

Cheers :)
 
50% absolute and negative margin is the best cross compat solution, display: table has problems with older ie, be aware that any parent element set to position: relative will effect an absolute child.
 
Back
Top Bottom