- 遮挡层,全屏
- 对话框上下左右居中
html
<div class="wrapper">
<div class="bg"></div>
<div class="contaier"></div>
</div>
css
.wrapper, .bg {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
overflow-y: auto
}
.bg {
background: #364252;
opacity: 0.7;
}
.contaier {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
width: 600px;
height: 500px;
background-color: red;
}
网友评论