垂直居中
1、transform
element {
position: relative;
top: 50%;
transform: translateY(-50%);
}
2、position
element {
height:200px;
width:200px;
position:absolute;
top:50%;
margin-top:-100px;
}
3、line-height
element {
height: 400px;
line-height: 400px;
}
这种方法只适合单行文字的水平垂直居中