How to hide scrollbar
- Previous Page Custom Scrollbar
- Next Page Show/Force Show Scrollbar
Learn how to hide scrollbars using CSS.
How to hide scrollbar
Adding overflow: hidden;
, which can hide both horizontal and vertical scrollbars at the same time.
Example
body { overflow: hidden; /* Hide scrollbars */ }
To hide only the vertical scrollbar or only the horizontal scrollbar, use overflow-y
or overflow-x
:
Example
body { overflow-y: hidden; /* Hide vertical scrollbar */ overflow-x: hidden; /* Hide horizontal scrollbar */ }
Please note thatoverflow: hidden
It will also remove the functionality of the scrollbar. Scrolling within the page is not possible.
Hide scrollbar while retaining functionality
To hide the scrollbar while still allowing scrolling, you can use the following code:
Example
/* Hide scrollbar for Chrome, Safari, and Opera */ .example::-webkit-scrollbar { display: none; } /* Hide scrollbar for IE, Edge, and Firefox */ .example { -ms-overflow-style: none; /* IE and Edge */ scrollbar-width: none; /* Firefox */ }
Webkit browsers (such as Chrome, Safari, and Opera) support non-standard ::-webkit-scrollbar
pseudo-element that allows us to modify the appearance of the browser scrollbar. Supported by IE and Edge -ms-overflow-style:
property, supported by Firefox scrollbar-width
properties, which allow us to hide the scrollbar while retaining its functionality.
Related pages
Tutorial:CSS Overflow
Reference Manual:CSS overflow Property
- Previous Page Custom Scrollbar
- Next Page Show/Force Show Scrollbar