Saturday, March 8, 2014

How to center a div element excatly to the center of the page i.e horizontally and vertically:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
  <style type="text/css">
#content  
{
background-color: #f00;
margin-top: -35px;
margin-left: -125px;
position: absolute;
top: 50%;
left: 50%;
width: 250px;
height: 70px;

}
  </style>
  </head>
  <body>
    <div id="content"> ... content ...gdfggggggggggggg</div>
  </body>
</html>

No comments:

Post a Comment