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的负值来实现居中。 负边距来实现,水平垂直居中。需要知道该元素的具体大小

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