<div class="father">
<div class="son"></div>
</div>
.father{
width:300px;
height:200px;
background:pink;
position:relative
}
.son{
width:30px;
height:30px;
background:red;
position:absolute;
top:0;/*很重要*/
bottom:0;/*很重要*/
margin:auto;/*很重要*/
}