方法一:flex
.box{
display: flex;
justify-content:center;
align-items:Center;
}
方法2:table-cell
.box{
display: table-cell;
vertical-align: middle;
text-align: center;
}
方法3:定位
.box span{
width: 50%;
height: 50%;
background: #000;
overflow: auto;
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
方法4: line-height
其余方法,均大同小异。参考即可