DIV水平居中显示代码仅需使用margin即可
让DIV居中显示,只需使用margin:0 auto;
即可。
<style>
.divcenter{width:300px; height:150px; background:#ccc; text-align:center; line-height:150px; margin:0 auto;}
</style>
<div class="divcenter">我现在是不是居中显示了?</div>
查看实例.divcenter{width:300px; height:150px; background:#ccc; text-align:center; line-height:150px; margin:0 auto;}
</style>
<div class="divcenter">我现在是不是居中显示了?</div>