So, I have an overlay like below (screenshot from example site).
当菜单(A 部分)打开时,它会在主 div(B 部分)上显示一个覆盖层。
但是,当菜单打开时,我仍然可以滚动主 div。
有没有办法在打开菜单(覆盖层)时禁用主 div(B 部分)上的滚动?
Thanks!
这是可以做到的。 HTML:
<div class="overlay">
<div class="overlay-content">
<p>I had a vision of a world without Batman. The Mob ground out a little profit and the police tried to shut them down one block at a time. And it was so boring. I've had a change of heart. I don't want Mr Reese spoiling everything but why should I have all the fun? Let's give someone else a chance. If Coleman Reese isn't dead in 60 minutes then I blow up a hospital.</p>
<p>You can swapnot sleeping in a penthouse... for not sleeping in a mansion. Whenever you stitch yourself up, you do make a bloody mess.</p>
<p>I'm Batman</p>
<p>Does it come in black?</p>
<p>Breathe in your fears. Face them. To conquer fear, you must become fear. You must bask in the fear of other men. And men fear most what they cannot see. You have to become a terrible thought. A wraith. You have to become an idea! Feel terror cloud your senses. Feel its power to distort. To control. And know that this power can be yours. Embrace your worst fear. Become one with the darkness.</p>
<p>You either die a hero or you live long enough to see yourself become the villain.</p>
</div>
</div>
<div class="background-content">
<p>I had a vision of a world without Batman. The Mob ground out a little profit and the police tried to shut them down one block at a time. And it was so boring. I've had a change of heart. I don't want Mr Reese spoiling everything but why should I have all the fun? Let's give someone else a chance. If Coleman Reese isn't dead in 60 minutes then I blow up a hospital.</p>
<p>You can swapnot sleeping in a penthouse... for not sleeping in a mansion. Whenever you stitch yourself up, you do make a bloody mess.</p>
<p>I'm Batman</p>
<p>Does it come in black?</p>
<p>Breathe in your fears. Face them. To conquer fear, you must become fear. You must bask in the fear of other men. And men fear most what they cannot see. You have to become a terrible thought. A wraith. You have to become an idea! Feel terror cloud your senses. Feel its power to distort. To control. And know that this power can be yours. Embrace your worst fear. Become one with the darkness.</p>
<p>You either die a hero or you live long enough to see yourself become the villain.</p>
</div>
CSS:
.overlay{
position: fixed;
top: 0px;
left: 0px;
right: 0px;
bottom: 0px;
background-color: rgba(0, 0, 0, 0.8);
}
.overlay .overlay-content {
height: 100%;
overflow: scroll;
}
.background-content{
height: 100%;
overflow: auto;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)