移动端滚动不让触发浏览器滚动效果
样式采用定位:absolute或fixed
.wrap{ position:fixed; width:100%; height:100%; top:0; left:0; touch-action:none; }
绑定事件的时候,不要阻止冒泡 (e.stopPropagation())
弹窗滚动穿透最佳解决办法
打开弹窗
var scrollTop = document.body.scrollTop||document.documentElement.scrollTop; document.body.style.cssText += 'position:fixed;top:-' + scrollTop + 'px;width:100%';//移动端fixed后 body宽度改变
关闭弹窗
var body = document.body; body.style.position = 'static'; var top = body.style.top; document.body.scrollTop = document.documentElement.scrollTop = -parseInt(top); body.style.top = '';