Forum Moderators: not2easy

Message Too Old, No Replies

DIv at middle

         

Gero_Master

6:27 pm on Mar 27, 2005 (gmt 0)

10+ Year Member



My page draws div's to the left side of the page... how can i make it draw them on middle (horizontal) to the page

birdbrain

7:40 pm on Mar 27, 2005 (gmt 0)



Hi there Gero_Master,

try this it may give you some ideas. ;)

<!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>
<title>centered divs</title>

<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />

<style type="text/css">
/*<![CDATA[*/
html, body {
height:100%;
margin:0px;
padding:0px;
}
#box1 {
width:200px;
padding:10px;
border:1px solid #000;
margin:10px auto 10px auto;
}
#box2 {
width:324px;
height:200px;
line-height:200px;
text-align:center;
border:3px double #000;
margin:30px auto 5px auto;
}
#box3 {
width:50%;
height:25%;
text-align:right;
background-color:#ccf;
margin: auto;
}
/*//]]>*/
</style>

</head>
<body>

<div id="box1">div one</div>
<div id="box2">div two</div>
<div id="box3">div three</div>

</body>
</html>

birdbrain

Robin_reala

10:36 pm on Mar 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Or for a shorter answer, give them this property in the CSS:

margin: 0 auto;