欢迎来到DIVCSS5查找CSS资料与学习DIV CSS布局技术!

negative margins负边距,会使结构塌陷,利用这个特点来实现。

<div class="parent-frame" style="position: relative;">
 
 利用绝对定位,配合margin的负值来实现居中。
 
 <div class="child-frame" style="position: absolute; top: 50%; left: 50%; margin-top: -51px; margin-left: -51px;">
 
 负边距来实现,水平垂直居中。需要知道该元素的具体大小
 
 </div>
 
</div>

利用绝对定位,配合margin的负值来实现居中。 负边距来实现,水平垂直居中。需要知道该元素的具体大小

html中div使用CSS实现水平/垂直居中的多种方式

如需转载,请注明文章出处和来源网址:http://www.divcss5.com/template/m58785.shtml