css垂直居中方法(细节慢慢补充)
1.固定定位
通过固定的值来进行居中定位
2.position+定位
1 position:absolute; 2 left:50%; 3 top:50%; 4 margin-left:元素宽的1/2 5 margin-top:元素高的1/2
3.flex布局
display:flex;
justify-content:center;
align-items:center;
flex的兼容性不太行。
4.table-cell
display: table-cell;
vertical-align: middle;
text-align: center;
table-cell兼容性不错。
5.transform
position:absolute;
left:50%;
top:50%;
transform:translate(-50%,-50%);

浙公网安备 33010602011771号