Gunnar Bittersmann: div zentrieren

Beitrag lesen

Hello out there!

Wie kann man einen div horizontal *und* vertikal zentrieren.

Alternativ zu [Detlef] in moderenen Browsern auch:

<!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">  
 <head>  
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />  
  <title>Test</title>  
  <style type="text/css">  
   [code lang=css]html {  
    display: table;  
    width: 100%;  
    height: 100%;  
   }  
   body {  
    display: table-cell;  
    width: 100%;  
    height: 100%;  
    vertical-align: middle;  
   }  
   div {  
    width: 150px;  
    height: 100px;  
    margin: auto;  
    border: 2px solid #999;  
    padding: 1em;  
   }

</style>
 </head>
 <body>
  <div>
   <p>Lorem ipsum dolor sit amet</p>
  </div>
 </body>
</html>[/code]

See ya up the road,
Gunnar

--
“Remember, in the end, nobody wins unless everybody wins.” (Bruce Springsteen)