1、display: flex;
span{
display: flex;
align-items:center;
}
2、display: table-cell;
display: table-cell;
vertical-align: middle;
3、 line-height
这种方法只适用于已知高度的情况
div{
height: 30px;
line-height: 30px;
}
4、 定位+位移
div{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
5、 margin
div{
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 20px;
height: 20px;
margin: auto;
}