Realize the effect that the background cannot slide after the pop-up box of the webpage

We often write effects such as the pop-up box of the mask layer, but the editor recently found that after the pop-up box appears, the background content information it covers can slide, and the experience is very bad, so how to prohibit the background sliding

very simple property

After the popup appears, set the body to hidden = "hidden";

body is set to auto when the popup is closed = "hidden"; 

This can achieve the effect, generally it is dynamically added
to set the overflow property of the body according to your event requirements.

Guess you like