①子绝父相
②设置小div上下左右都为0,margin:auto;
<style>
.big{
width: 500px;
height: 500px;
border: 3px solid #f00;
position: relative;
}
.small{
width: 100px;
height: 100px;
background-color: green;
border: 2px solid #000;
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
margin: auto;
}
</style>
<div class="big">
<div class="small"></div>
</div>