- flex 弹性盒布局法
.box {
display: flex;
justify-content: center;
align-items: center;
}
- 绝对定位
.box {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
border: 1px solid pink;
width: 100px;
height: 100px;
}