css布局在IE和FF中居中

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>随时,随地,任何事情,一个电话!</title>

<link rel="stylesheet" href="css/index.css" type="text/css"/>
</head>

<body>

<!--容器-->
<div class="container">
</div>

</body>
</html>

/* CSS Document */
body {
    margin:0px;
    padding:0px;
    font:"宋体" 12px;
}

.container {
    margin:0 auto;
    padding:0px;
    width:1000px;
    height:auto;/*高度不固定,自适应*/
    border:1px solid red;
}

.container:after {
    content:".";
    display:block;
    clear:both;
    height:0px;
    visibility:hidden;
}

有 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

body可以不用设为text-align:center;

posted @ 2012-06-19 16:34  FireFile  阅读(108)  评论(0编辑  收藏  举报