I am using a mac trackpad.How to prevent the page going back and next to visited pages on horizontal scroll ?.
I tried to prevent the wheel events but it doesn't works most of the time.
container.addEventListener('wheel', function(ev) {
ev.preventDefault();
ev.stopPropagation();
return false;
}, {passive: false, capture: true});
even I tried blocking with mousewheel event which also leads to page navigation.
To hide the horizontal scrollbar and prevent horizontal scrolling, use overflow-x: hidden: HTML. CSS.
Add overflow: hidden; to hide both the horizontal and vertical scrollbar.
Open Settings > devices > mouse & touchpad > Turn the Scroll inactive windows when I hover over them option on. Was this reply helpful? I fixed it myself.
In short: if you use width: 100vw on a page that has a vertical scrollbar you end up with a horizontal overflow. The easy fix is to use width: 100% instead. Percentages don't include the width of the scrollbar, so will automatically fit.
You can do this with CSS.
html {
overscroll-behavior-x: contain;
}
Documented for Chrome here.
contain - prevents scroll chaining. Scrolls do not propagate to ancestors but local effects within the node are shown. For example, the overscroll glow effect on Android or the rubberbanding effect on iOS which notifies the user when they've hit a scroll boundary. Note: using overscroll-behavior: contain on the html element prevents overscroll navigation actions.
Tested on chrome version 77 OSX
Note: This is still a non-standard CSS property: https://developer.mozilla.org/en-US/docs/Web/CSS/overscroll-behavior
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With