#mainBody{
width: 960px;
margin-left:auto;
margin-right:auto;
}
IE中必须在body里面加上"text-align:center "!
代码如下:
<!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>
<title>
DIV在IE和FF中的居中处理
</title>
<style type="text/css" rel="stylesheet">
body{
margin:0px;
}
#main{
margin:auto;
width:600px;
height:100%;
background-color:#cccccc;
}
</style>
</head>
<body>
<div id="main">
DIV在IE和FF中的居中处理
</div>
</body>
</html>