body设置一个DIV,并让这个DIV居中显示,怎样做?

想设置一个600px宽的页面,并居中显示
下面的代码怎么改?

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>

</div>
</form>
</body>
</html>
margin是个什么东西?

第一,要给DIV设置一个宽度
第二,要把BODY设置text-align:center
这种方法只针对IE浏览器有效。
如果要针对火狐等标准浏览器,必须设置div的margin为auto
温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2017-09-25
body style="text-align:center;"

div style="width:600px;margin-left:auto;margin-right:auto;"

margin就是对象与其容器的边框之间的距离本回答被提问者采纳
第2个回答  2009-03-14
BODY 设置text-align:center;这是一种方法
还有另一种就是设置该DIV的margin-left:auto;margin-right:auto;
第3个回答  2009-03-13
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body style="text-align:center">
<form id="form1" runat="server">
<div style="width:600px;">

</div>
</form>
</body>
</html>
第4个回答  2009-03-14
<center>
<div>

</div>
</center>
相似回答