1、margin: auto
div {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
}
2、transform
div {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
3、容器高、宽已知,margin
div {
width: 400px;
height: 400px;
position: absolute;
top: 50%;
left: 50%;
margin: -200px -200px;
}