Jonathanh Haas: Ein div-Element vertikal und horizontal zentrieren?

Beitrag lesen

Etwa so:

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<title>home</title>
<style type="text/css">
 a {text-decoration: none;}
 a:link {color:#000000}
 a:visited {color:#000000}
 a:active {color:#000000}
 a:hover {color:#ff0000}
 html {height:100%;}
 body {margin:0;height:100%;}
</style>
</head>
<body>
<div style="position:absolute;top:50%;left:50%;width:0;height:0;">
<div style="position:relative;top:-10em;left:-20em;width:40em;height:20em;border:1px solid green;background:#AEF;z-index:10;">
<h1>DIV DIV DIV</h1>
</div>
</div>
</body>
</html>

(getestet mit Firefox und Konqueror)