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.rs2pl.com/template/m58785.shtml