div水平垂直居中显示
绝对定位div,top和left设置为50%.
margin-top为 1/2 * height;margin-left为 1/2 * width
.center{
width:200px;
height:150px;
background-color:#0066CC;
position:absolute;top:50%;left:50%;
margin-top:-75px;
margin-left:-100px;
}
.center2{
margin-left: auto;
margin-right: auto;
}
<div class="center"></div>