<style type="text/css">
*{margin: 0;padding: 0}
html,body{height: 100%}
.outer-wrap{
height: 100%;
position: relative;
background-color: rgba(0, 0, 0, .5);
}
.login-panel{
width: 400px;
height: 300px;
background-color: orange;
position: absolute;
top: 50%;
left: 50%;
margin-top: -150px;
margin-left: -200px;
}
</style>
<div class="box">
<section class="inner"></section>
</div>
`
.box {
display: flex;
justify-content: center; /* 水平居中 */
align-items: center; /* 垂直居中 */
width: 1000px;
height: 600px;
border: 1px solid red;
}
.inner {
width: 300px;
height: 200px;
background-color: red;
}
``