日期:2014-05-17  浏览次数:20555 次

IE8无法居中的问题,
为什么我用IE6,IE7测试以下网页可以居中,而在ie8却无法居中啊,
HTML:

<!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" type="text/css" href="style/basic.css"/>
</head>
<body>
<div id="header">
   
</div>
<div id="content">
  <div id="nav"></div>
  <div id="main"></div>

</div>
<div id="footer">版权所有&nbsp;翻版必究</div>
</body>
</html>

CSS:
*{
  padding:0;
  margin:0;
}
body{
font-size:12px;
background:#fff;
text-align:center;
}
ul{
list-style-type:none;
}
a{
  text-decoration:none;
  border:0;
}
img{
border:0;
}
#header{
width:980px;
height:60px;
background:red;
 
}
#content{
width:980px;
height:600px;
}
#nav{
width:120px;
height:600px;
background:blue;
float:left;
}
#main{
width:859px;
height:600px;
background:pink;
float:right;
}
#footer{
width:980px;
background:yellow;
clear:both;
}

------解决方案--------------------
将#header , #content , #footer 设置 margin-left:auto;margin-right:auto;

另 不要使用 *选择符


------解决方案--------------------
rpwt

你在其他电脑上试下吧

我的ie8可以居中
------解决方案--------------------
是的,设置margin:0 auto;就可以了
------解决方案--------------------
margin-left:auto;margin-right:auto;