css 元素垂直居中

通用

<div id="parent">
<div id="child">Content here</div>
</div>
#parent {display: table;}
#child {
display: table-cell;
vertical-align: middle;
}
/*低版本 IE fix bug*/
#child {
display: inline-block;
}

定位居中

<div id="parent">
<div id="child">Content here</div>
</div>
#parent {position: relative;}
#child {
position: absolute;
top: 0;
left: 0;
height: 0;
width: 0;
margin: auto;
}
原文地址:https://www.cnblogs.com/chenglj/p/7426270.html