如何让div水平居中
代码实例:
<!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" />
<meta name="author" content="http://www.softwhy.com/" />
<title>蚂蚁部落</title>
<style type="text/css">
.mytest
{
width:200px;
height:200px;
border:1px solid red;
margin:0px auto;
}
</style>
</head>
<body>
<div class="mytest">我将要浮动</div>
</body>
</html>
给对象添加margin:0px auto即可实现此效果。
后来都会美好的!