22/01/2025
Goodbye, Ugly Scrollbars! Here’s How to Hide Them
Give Me 2 Minutes and Make Scrollbars Disappear Like Magic
This Tiny Detail Could Set Your Website Apart
A scrollbar shows on a page whenever there is an overflow happening. It lets the user know that a particular page can be scrolled horizontally or vertically.
Some issues developers come across when dealing with scrollbars include not putting accessibility in mind and not testing them across multiple browsers.
Knowing how to style, display, or hide scrollbars would make you stand out because, instead of the browser’s default styling, you can give your desired style that fits your brand.
To show the scrollbar, your page needs to overflow. By default, the overflow is visible, so only when your content can’t contain the page then the scrollbar would show up, or you can set it to show by default by setting overflow: scroll.
Knowing now that you are not just limited to the default style that allows all browsers to give their preferred style to the scrollbar, instead, you can give something unique that would be the same for all browsers.
Styling the scrollbar and making it unique.
Neat Pages Start Here: Mastering Hidden Scrollbars
Hiding the visibility of your scrollbar is different from making overflow hidden. If your scrollbar is hidden, your page won’t be able to scroll because you have given overflow: hidden to your page.
Hiding scrollbars should be based on the design, user experience, and some other factors. Note: also take care of accessibility issues for people that need accessibility features, like screen readers and so on.
A scrollbar, if not handled well, can prevent your design from being neat. There might be some areas on your page where you want the content to scroll but also avoid the scrollbar — this is when hiding the scrollbar comes in handy.
Hiding Scrollbars in CSS:
It works by giving your div, table, or any tag you want to apply the overflow to, a class name of your choice. In this case, I would use scrollbar-hide.
index.html
Index.css
scrollbar-hide::-webkit-scrollbar {
display: none;
}
scrollbar-hide {
-ms-overflow-style: none;
scrollbar-width: none;
}
Note:
The ::-webkit-scrollbar is a CSS pseudo-element that allows you to customize the appearance of scrollbars in browsers that use the WebKit rendering engine (e.g., Chrome, Safari, and newer versions of Edge).
The -ms-overflow-style is a CSS property specific to Internet Explorer (IE) and Edge (prior to version 79, which switched to the Chromium engine). It controls the appearance of the scrollbars in a web page or element.
Now you can go ahead improving your styling — not just letting scrollbars affect your design. You now have the power to disable or hide your scrollbar.
A scrollbar, which is caused by page overflow, can also affect the layout, style, or design of a page. Understanding how it works and how to go about it gives you so much flexibility to tweak it to your desired output.
Don't forget to like,comment and follow.