设置div的css为
margin:0 auto;text-align:center;
效果(中间的div是居中的):
效果(中间的div是居中的):
居中
例子代码
<div style="width:400px;height:100px;border: 1px solid blue;">
<div style="width:300px;height:80px;margin:0 auto;text-align:center;border: 1px solidblue;">
<p>
居中
</p>
</div>
</div>