這是一個系列,記錄我前端開發常用的代碼,小常識,有些是參考網上代碼,(講的可能有點爛,求不要打臉,嚶嚶嚶~~)送給那些需要的人。可以相互交流,喜歡的加我吧。
Wx: Lxp911221
js 彈出框 背景不滑動 方案
const bodyTag = window.document.getElementsByTagName('body')[0]
// val 爲彈出框當前狀態
val ? bodyTag.classList.add('com-mask-background') : bodyTag.classList.remove('com-mask-background')
css
.com-mask-background{
position: fixed;
width: 100%;
height: 100%;
}