1,弹性盒子
.box{
width: 500px;
height: 500px;
background-color: green;
display: flex;
justify-content: center;
align-items: center;
}
.box1{
width: 100px;
height: 100px;
background-color: yellow;
}
2,定位子绝父相
.box {
position: relative;
width: 400px;
height: 500px;
background-color: green;
}
.box1 {
width: 100px;
height: 100px;
position: absolute;
left: 50%;
top: 50%;
margin-left: -50px;
margin-top: -50px;
background-color: yellow;
}
3,子盒子变成行内块
.box {
width: 500px;
height: 500px;
background-color: green;
text-align: center;