移动端处理弹框穿透问题

添加一个样式  

body.modal-open{
position: fixed;
 width: 100%;

var ModalHelper = (function(bodyCls) {
var scrollTop;
return {
//打开弹窗
afterOpen: function() {
scrollTop = document.scrollingElement.scrollTop;
document.body.classList.add(bodyCls);
document.body.style.top = -scrollTop + 'px';
},
//关闭弹窗
beforeClose: function() {
document.body.classList.remove(bodyCls);
// scrollTop lost after set position:fixed, restore it back.
document.body.style.top = 0;
document.scrollingElement.scrollTop = scrollTop;
}
};
})('modal-open');

猜你喜欢

转载自www.cnblogs.com/aotuboke/p/11096675.html