5

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
  • 11,875
  • 18
  • 85
  • 108
flipps
  • 124
  • 1
  • 1
  • 12

3 Answers3

16

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
  • 170,088
  • 45
  • 397
  • 571
Bhoot Biswas
  • 192
  • 7
7

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
  • 78,590
  • 9
  • 125
  • 172
davaus
  • 1,145
  • 13
  • 16
6

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
  • 657
  • 6
  • 12