<div class="box">
<div class="center">
fgd
</div>
</div>
<style>
.box {
width: 100vw;
height: 100vh;
background-color: red;
display: flex; /*第一行*/
}
.center {
width: 500px;
height: 500px;
background-color: pink;
margin: auto; /*第二行*/
}
</style>
效果: