How to hide scrollbar in Firefox?

CssFirefox

Css Problem Overview


I just found out how to hide the scrollbar in Google Chrome, I did it with this code:

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

The only problem is that this doesn't work on Firefox. I tried many ways to do it but it still doesn't work.

Css Solutions


Solution 1 - Css

You can use the scrollbar-width rule. You can scrollbar-width: none; to hide the scrollbar in Firefox and still be able to scroll freely.

body {
   scrollbar-width: none;
}

Solution 2 - Css

To hide scroll bar on Chrome, Firefox and IE you can use this:

.hide-scrollbar
{
    overflow: auto;
    -ms-overflow-style: none; /* IE 11 */
    scrollbar-width: none; /* Firefox 64 */
}

Solution 3 - Css

I was able to hide the scrollbar but still be able to scroll with mouse wheel with this solution:

html {overflow: -moz-scrollbars-none;}

Download the plugin https://github.com/brandonaaron/jquery-mousewheel and include this function:

jQuery('html,body').bind('mousewheel', function(event) {
    event.preventDefault();
    var scrollTop = this.scrollTop;
    this.scrollTop = (scrollTop + ((event.deltaY * event.deltaFactor) * -1));
    //console.log(event.deltaY, event.deltaFactor, event.originalEvent.deltaMode, event.originalEvent.wheelDelta);
  });

Solution 4 - Css

This is what I needed to disable scrollbars while preserving scroll in Firefox, Chrome and Edge in :

          @-moz-document url-prefix() { /* Disable scrollbar Firefox */
            html{
              scrollbar-width: none;
            }
          }
          body {
            margin: 0; /* remove default margin */
            scrollbar-width: none; /* Also needed to disable scrollbar Firefox */
            -ms-overflow-style: none;  /* Disable scrollbar IE 10+ */
            overflow-y: scroll;
          }
          body::-webkit-scrollbar {
            width: 0px;
            background: transparent; /* Disable scrollbar Chrome/Safari/Webkit */
          }

Solution 5 - Css

For webkit use following:

::-webkit-scrollbar {
    width: 0px;  /* remove scrollbar space */
    background: transparent;  /* optional: just make scrollbar invisible */
}

For Mozilla Firefox use following code:

@-moz-document url-prefix() {
    html,body{overflow: hidden !important;}
}

and if scrolling does not work then add

element {overflow-y: scroll;}

to specific element

Solution 6 - Css

I used this and it worked. https://developer.mozilla.org/en-US/docs/Web/CSS/scrollbar-width

html {
scrollbar-width: none;
}

Note: User Agents must apply any scrollbar-width value set on the root element to the viewport.

Solution 7 - Css

For more recent version of Firefox the old solutions don't work anymore, but I did succesfully used in v66.0.3 the scrollbar-color property which you can set to transparent transparent and which will make the scrollbar in Firefox on the desktop at least invisible (still takes place in the viewport and on mobile doesn't work, but there the scrollbar is a fine line that is placed over the content on the right).

overflow-y: auto; //or hidden if you don't want horizontal scrolling
overflow-y: auto;
scrollbar-color: transparent transparent;

Solution 8 - Css

This is something of a generic solution:

<div class="outer">
 <div class="inner">
    Some content...
 </div>
</div>

<style>
 .outer {
 overflow: hidden;
}
 .inner {
 margin-right: -16px;
 overflow-y: scroll;
 overflow-x: hidden;
}
</style>

The scroll bar is hidden by the parent div.

This requires you to use overflow:hidden in the parent div.

Solution 9 - Css

Just in case, if someone is looking for a hack to somehow make the scrollbar invisible in firefox(79.0).

Here's a solution that successfully works for Chrome, IE, Safari, and makes the scrollbar transparent in Firefox. None of the above worked for firefox(79.0) in truly hiding the scrollbar.

Please if anyone finds a way to do it without changing the color, it will be very helpful. Pls comment below.

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

.scrollhost ::-moz-scrollbar {
  display: none;
 
}
 
.scrollhost {
  overflow: auto;
  -ms-overflow-style: none;
  scrollbar-color: transparent transparent; /*just hides the scrollbar for firefox */
}

Solution 10 - Css

I got it working for me in ReactJS using create-react-app by putting this in my App.css:

@-moz-document url-prefix() {
  html,
  body {
    scrollbar-width: none;
  }
}

Also, the body element has overflow: auto

Solution 11 - Css

If you want the scrollbar gone on the whole body and still have functionality, add this under your style tags at the top of your html code. This solved the problem for me.

Reference: https://careerkarma.com/blog/hide-scrollbar/

      * {

           scrollbar-width: none; /* Firefox implementation */

       }

Solution 12 - Css

Try using this:

overflow-y: -moz-hidden-unscrollable;

Solution 13 - Css

In some particular cases (the element is on the very right of the screen, or its parent overflow is hidden) this can be a solution:

@-moz-document url-prefix() {
  .element {
    margin-right: -15px;
  }
}

Solution 14 - Css

I tried everything and what worked best for my solution was to always have the vertical scrollbar show, and then add some negative margin to hide it.

This worked for IE11, FF60.9 and Chrome 80

body {
  -ms-overflow-style: none; /** IE11 */
  overflow-y: scroll;
  overflow-x: hidden;
  margin-right: -20px;
}

Solution 15 - Css

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

It will not work in Firefox, as the Firefox abandoned the support for hidden scrollbars with functionality (you can use overflow: -moz-scrollbars-none; in old versions).

Solution 16 - Css

if you want to hide extension popup option on Firefox, try following

  html {
    scrollbar-width: none;
  }

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDaan KleijngeldView Question on Stackoverflow
Solution 1 - CssGeorge FlintView Answer on Stackoverflow
Solution 2 - CssRowinView Answer on Stackoverflow
Solution 3 - CssCrazyScientistView Answer on Stackoverflow
Solution 4 - CssLogan PowellView Answer on Stackoverflow
Solution 5 - Cssromal tandelView Answer on Stackoverflow
Solution 6 - CssKy_PhamView Answer on Stackoverflow
Solution 7 - CssChris AelbrechtView Answer on Stackoverflow
Solution 8 - CssMylesView Answer on Stackoverflow
Solution 9 - CssAditya PatnaikView Answer on Stackoverflow
Solution 10 - CssDante Souza e SouzaView Answer on Stackoverflow
Solution 11 - CssBuddyCarverView Answer on Stackoverflow
Solution 12 - CsspeeterView Answer on Stackoverflow
Solution 13 - CssgazdagergoView Answer on Stackoverflow
Solution 14 - CssJohn CarrollView Answer on Stackoverflow
Solution 15 - CssManmeet KaurView Answer on Stackoverflow
Solution 16 - CssTonyView Answer on Stackoverflow