Skip to content
Advertisement

Hide scroll and implement it with JS

I’m a beginner to HTML and JavaScript.

I’m building a tabs bar, in which I want to have the option to scroll it horizontally, not with a traditional browser scroll, but with arrow buttons that I’ve created.

Here is how my tabs bar looks like: enter image description here

This is the best I’ve managed to do:

JavaScript
JavaScript
JavaScript

I manage to go to the JavaScript function, but have no idea how to scroll horizontally by JS code. Also I would like to hide the OOTB scroll.

I’ve also created a fiddle: https://jsfiddle.net/b40c19h6/1/

Advertisement

Answer

Use overflow-x: hidden to hide the scrollbar and you can use the scrollLeft or scrollBy function on your tabs element to move the content.

Here how you can do it:

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement