On the problem that css mask layers can be scrolled

wrote a css mask, which is similar to the effect of the bootstrap pop-up window

<div class="alert-container">
    <div class="alert-content"></div>
</div>

set the css of alert-container to

position: fixed;
background: rgba(0,0,0,0.70);
top: 0;
bottom: 0;
left: 0;
right: 0;

but the content under the background can be scrolled, and I don"t know how to solve the problem that can be scrolled in the following part

I wonder if there is a way not to use js

Mar.02,2021

  1. set overflow; for body when the mask is turned on
  2. $('body'). Css ("overflow", "hidden")

when the mask layer pops up, set the height of the visual area of the height: browser for body; and set the body: overflow:hidden; overflow hide; so that you can't scroll, and remove the style previously set by body when the mask layer is turned off;

Menu