在做项目时,用到了弹出框,下边要有一层遮罩。写了一个简单的遮罩,拉动滚动条后发现,遮罩层只是遮住了视口,下面看不到根本没遮住,后来经过度娘后才有了解决方法。
有问题的遮罩层代码
.modal .modal-shadow {
opacity: 0.3;
filter: alpha(opacity=30);
background-color: gray;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 100;
}
解决问题后的遮罩层代码,其实只要把absolute换成fixed即可。
.modal .modal-shadow {
opacity: 0.3;
filter: alpha(opacity=30);
background-color: gray;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 100;
}