当模式覆盖打开时,我试图阻止页面正文滚动(根本)。
模态覆盖整个屏幕({position: fixed;top:0;left:0;right:0;bottom:0;}
),并且它有自己的滚动。然而,当我在模式窗口上运行到滚动的末尾时,主窗口开始在它后面滚动。我已经尝试了我能想到的一切来让主体停止滚动。这些东西没有起作用:
CSS
body {
overflow: hidden;
pointer-events: none;
-webkit-overflow-scrolling: none;
}
#content { /* which contains all the non-modal content of the body */
-webkit-transform: scale(0);
position: relative; left: 100%;
}
- 使用iScroll
- 阻止窗口或正文的滚动事件
- 阻止body上的touchstart事件
看起来你已经很接近了。
当你的模态打开时,试试这个CSS:
body{
overflow:visible;
max-height:100%; /* or 100px or something smaller than the screen if your viewport isn't set */
height:100% /* or 100px or something smaller than the screen */
}