1. flex布局方法
<div class="father">
<div class="child"> </div>
</div>
<style>
.father {
display: flex;
justify-content: center;
align-items: center;
}
</style>
2. position 方法
<div class="father">
<div class="child"> </div>
</div>
<style>
.father {
position: relative;
}
.child {
left: 0;
position: absolute;
top: 0;
right: 0;
bottom: 0;
margin: auto;
}
</style>