How To Hide Scrollbar Across All Browsers With Css
  • Work
    ,
  • About
    ,
  • Blog
    ,
  • Contact
Get In Touch
  • Home
  • Work
  • About
  • Blog
  • Contact

Developer & Designer

OreoGrapher © 2024
Published on: Wed Sep 11 2024
By - OreoGrapher
css tricks

How to hide Scrollbar across all Browsers with CSS

How to hide Scrollbar across all Browsers with CSS Image

Scrollbars are a fundamental part of web design, but sometimes you might want to hide them for aesthetic reasons or to improve the user experience. Whether you're designing a full-screen app or a minimalistic website, you might find yourself needing to remove scrollbars from your pages. This post will guide you through the process of removing scrollbars in various browsers using CSS.

Why to hide Scrollbar?

Removing scrollbars can help in scenarios such as:

  • Full-screen applications: Where you want a clean, distraction-free interface.
  • Design mockups: Where you need to maintain a specific design look without the browser’s default scrollbars interfering.
  • Custom scrollbars: Where you're implementing your own scrolling solutions and don’t want the default scrollbars to appear.

CSS Code to hide Scrollbar

To remove scrollbar across all major browsers, you can use a combination of CSS rules. Here's a comprehensive approach:

body {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

::-webkit-scrollbar {
  display: none;
}

If you want to hide the scrollbar in a specific area, you can add the .hide-scrollbar class to that area.

.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

Explanation of Each CSS Rule

-ms-overflow-style: none;

This property is used for Internet Explorer and Edge to hide scrollbars.

scrollbar-width: none;

This property targets Firefox and hides scrollbars. It’s a part of the CSS Scrollbars Module Level 1.

::-webkit-scrollbar { display: none; }

This rule is for WebKit browsers like Chrome and Safari. The ::-webkit-scrollbar pseudo-element targets the scrollbar itself and hides it.

Happy coding!

Leave a Comment

No comments yet

Similar Blogs

(0)