5

I have been using chrome for the longest time of my life. When I made my website and wanted to hide a scrollbar that appeared in my sidebar menu, I just used overflow: auto; in CSS, and then .sidebar_menu::-webkit-scrollbar {display: none;}. So there was no visible scrollbar, and I could scroll through the sidebar menu with my mouse wheel.

Yesterday, I started using Mozilla Firefox, and I realized that the scrollbar is vidible, and .sidebar_menu::-moz-scrollbar {display: none;} didn't work. This scared me to be honest, as I cannot see a way to get out of this. I just want it to be the same in chrome and Mozilla. At least this scrollbar thing.

Xoog
  • 908
  • 1
  • 10
  • 30
Jakub Chaloupka
  • 177
  • 1
  • 3
  • 12
  • You can try to get this library. It's a custom scroll js library and might help you. http://rocha.la/jQuery-slimScroll – Dinca Adrian Jan 11 '18 at 13:38
  • There's nothing like that for Firefox. Or IE, or Edge, or anything non-webkit. Safest bet would be to overflow:hidden the element, then use javascript to adjust the (negative) margin-top on scroll – Facundo Corradini Jan 11 '18 at 13:42
  • There is no fix, can oonly hack this one --> https://stackoverflow.com/questions/19580366/hide-scrollbar-in-firefox – Ylama Jan 11 '18 at 13:44

4 Answers4

6

Since Firefox 64, is possible to use new specs for a simple Scrollbar styling (not as complete as in Chrome with vendor prefixes).

In this example is possible to see a solution that combine different rules to address both Firefox and Chrome with a similar (not equal) final result:

The key rules are:

For Firefox

.scroller {
  overflow-y: scroll;
  scrollbar-color: red green;
  scrollbar-width: thin;
}

For Chrome

.scroller::-webkit-scrollbar-track
{
    background-color: green;
}

.scroller::-webkit-scrollbar
{
    width: 8px;
    background-color: #F5F5F5;
}

.scroller::-webkit-scrollbar-thumb
{
    background-color: red;
}

In the example linked are used also additional styles for Chrome to improve final style (such as rounded corners and shadows)

Luca Detomi
  • 5,564
  • 7
  • 52
  • 77
1

The scrollbar (normally) can't be modified. This is up to the browsers to handle how it will look like.

But, you can do it because of vendor prefixes. Those are prefixes you use that target specific browsers, such as

  • -o- for Opera
  • -moz- for Mozilla
  • -webkit- for Safari, Chrome, Android ...
  • -ms- for IE and Edge

You were right to try it, unfortunately there's no equivalent for Mozilla. You can take a look at this topic to try to find a solution, but honestly, you should just give up, almost no one is paying attention to that ...

1

Just in case someone stumbles across this, you can easily achieve the same effect in Firefox using:

.sidebar_menu {
    overflow: auto;
    scrollbar-width: none; /* hide the scrollbar in FF */
}

As stated by the other answers, FF currently only supports scrollbar-width: thin|none and scrollbar-color: #fgcolor #bgcolor without any pseudo CSS selectors or vendor prefixes. A cross-browser solution would be:

 /* Hide scrollbar for Chrome, Safari and Opera */
.sidebar_menu::-webkit-scrollbar {
    display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
.sidebar_menu {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
Shaun Mitchell
  • 2,306
  • 2
  • 15
  • 10
0

I believe that -webkit-scrollbar is not supported in Firefox. Although you can look for javascript libraries, which will do what you need.