I'm trying to disable horizontal scroll on a website; but without affecting the vertical.
I have a script that works like a slider by sliding the "body" of the page to the left and revealing more content. However, this creates an extra empty space on the right.
I have to disable horizontal scrolling so that users do not see this empty space. I have tried the following; but it disables both horizontal and vertical scrolling:
window.onscroll = function () {
window.scrollTo(0,0);
}
I've tried the overflow-x:hidden
style but that does not work when the width of body
is dynamic and not static.
Question:
Is there any way to modify my script to disable horizontal scrolling and keep the vertical running?
Original question: link