我正在尝试禁用导航滑动。 当用户向左或向右滑动时,我不希望网页返回或转发。
我注意到我们可以在html元素上将touch-action设置为none来阻止该行为。 但是,当滚动具有一些溢出的子元素时,它将“链接”滚动然后将允许后向导航。
所以我想在html元素上添加-ms-scroll-chaining:none,但它只在元素滚动时才有效。 所以添加溢出:在html上滚动实际上就可以了。但现在我在其他浏览器上显示了滚动条。
这样做的正确方法是什么?
html {
-ms-touch-action: none; /* Doesn't work if scrolling from child element */
-ms-scroll-chaining: none; /* Works only with the next line */
overflow: scroll; /* With this line all the other browsers have a scrollbar */
}
答案 0 :(得分:4)
我用过这个:
@media screen and (-ms-high-contrast: none) {
// Windows 8+ IE only
html {
overflow-x: scroll;
-ms-touch-action: none;
-ms-overflow-style: none;
-ms-scroll-chaining: none;
}
}
答案 1 :(得分:0)
你试过吗
body, html {
-ms-touch-action:none;
}
并且对于每个可以滚动的类(Y轴)都适用
-ms-scroll-chaining: none;
在我的项目中,我们有专门的课程来滚动舒适的东西:
.scroll-y {
overflow-y: auto;
overflow-x: hidden;
-ms-scroll-chaining: none;
}
为我工作