弹性盒方法
①先让大div变为弹性盒 display:flex;
②在大div上设置水平居中:justify-content: center;
③在大div上设置垂直居中:align-items: center;
<style>
.big{
width: 500px;
height: 500px;
border: 3px solid #f00;
display: flex;
justify-content: center;
align-items: center;
}
.small{
width: 100px;
height: 100px;
background-color: green;
}
</style>
<div class="big">
<div class="small"></div>
</div>