How to hide the scroll bar while still being able to scroll with CSS?

Spread the love

Sometimes, we want to hide the scroll bar while still being able to scroll with CSS.

In this article, we’ll look at how to hide the scroll bar while still being able to scroll with CSS.

How to hide the scroll bar while still being able to scroll with CSS?

To hide the scroll bar while still being able to scroll with CSS, we can set the scrollbar-width CSS property.

For instance, we write

.container {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.container::-webkit-scrollbar {
  display: none;
}

to set scrollbar-width to none to hide the scroll bar while letting us scroll.

Conclusion

To hide the scroll bar while still being able to scroll with CSS, we can set the scrollbar-width CSS property.

Leave a Reply

Your email address will not be published. Required fields are marked *