<div class="warp">
<div class="container"></div>
</div>
flex布局
.warp {
dispaly: flex;
justify-content: center;
algin-items: center;
}
transform + position: absolute
.warp {
posotion: relative;
}
.container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
}
负margin + position: absolute
.container {
position: absolute;
top: 50%;
left: 50%;
margin: -50% 0 0 -50%;
}
margin: auto + position: absolute
.container {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
}