垂直居中的孩子我有幾個孩子http://jsfiddle.net/thiswolf/FUqSP/父DIV和我想的是含child.For實例中垂直居中子內的每個格我想中心child_two在child_one。我有這個CSS有共同的父
.parent{
width:300px;
height:300px;
background-color:orange;
display:table-cell;
vertical-align:middle;
}
.child_one{
width:100px;
height:100px;
background-color:purple;
margin-left:auto;
margin-right:auto;
}
.child_two{
width:50px;
height:50px;
background-color:pink;
margin-left:auto;
margin-right:auto;
}
.child_three{
width:25px;
height:25px;
background-color:yellow;
margin-left:auto;
margin-right:auto;
}
.child_four{
width:12px;
height:12px;
background-color:red;
margin-left:auto;
margin-right:auto;
}
,這是HTML
<div class="parent">
<div class="child_one">
<div class="child_two">
<div class="child_three">
<div class="child_four">
</div>
</div>
</div>
</div>
</div>
閱讀此:http://www.vanseodesign.com/css/vertical-centering/它提出了一些很好的方法來實現對中 – Mik378