<div id="box">test vertical align</div>
#box {
width: 300px;
height: 300px;
background: #ddd;
display: flex;
align-items: center;/*垂直居中*/
justify-content: center;/*水平居中*/
}
使用flex布局
display: flex;
align-items: center;