1.使用绝对定位和变换
<style>
.parent {
position: relative;
}
.child{
position: absolute;
top: 50%;
left: 50%;
transform (-50%, -50%)
}
</style>
2.用flex来实现
<style>
.centered {
display: flex;
justify-content: center;
align-items: center;
}
</style>