3

I am working with bootstrap 4. I would like to know if there is a way to change the scrollbar style. I just tried with webkit mode, but does not work.

I can't see any changes

peterh
  • 1
  • 15
  • 76
  • 99
flipps
  • 104
  • 1
  • 1
  • 11

3 Answers3

13

The following code will works for webkit

::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); 
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    border-radius: 10px;
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5); 
}
Brad Larson
  • 169,393
  • 45
  • 393
  • 567
Bhoot Biswas
  • 163
  • 6
6

Bhoot's code above works, but I added a backgound-color for the thumb because I am using a dark background.

::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 6px rgba(200,200,200,1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background-color:#fff;
    -webkit-box-shadow: inset 0 0 6px rgba(90,90,90,0.7);
}
Fyodor Soikin
  • 74,930
  • 8
  • 118
  • 160
davaus
  • 1,085
  • 13
  • 16
3

If you are trying on any div or elements for scroll bar customization, please assign and use element id in the CSS as below,

<div class="cardsContainer" id="cards-container">

#cards-container::-webkit-scrollbar {
    width: 8px;
    background-color: #F5F5F5;
}


#cards-container::-webkit-scrollbar-track {
    box-shadow: inset 0 0 6px rgba(104, 140, 240, 0.3);
  }

#cards-container::-webkit-scrollbar-thumb {
    background-color: lightblue;
    outline: 1px solid slategrey;
}

The above way, it worked for me, even though it didn't work when I tried as follows,

::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); 
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    border-radius: 10px;
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5); 
}
mramsath
  • 462
  • 4
  • 10