Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Styling ::-webkit-scrollbar-track not working

Tags:

css

scroll

I'm trying to style the track of the scroll bar. Whenever I style the track:

 div::-webkit-scrollbar-track {
    background-color: blue;
 }

Nothing changes.

Whenever I style the scrollbar:

div::-webkit-scrollbar {
    background-color: blue;
}

The entire scroll bar is blue, no visible thumb

What am I missing here?

Edit:

I'm working in Chrome. What's odd is that the scroll bars in all my overflow containers just started showing up. Before they were invisible and the scroll thumb would only appear when hover or scrolling (can't remember which, but it definitely wasn't always there). Firefox seems to be giving the desired behavior.

Did something change with Chrome scrollbars lately?

like image 797
skwny Avatar asked May 27 '17 03:05

skwny


1 Answers

I know this thread is a few years old but I want to add a general answer to why it wasn't working. From my experience

you always have to set at least some attribute (like e.g. the background-color) of the whole ::-webkit-scrollbar { }

to be able to edit the ::-webkit-scrollbar-thumb { } and other parts of the scrollbar.

Hope this increases the general understanding.

like image 197
LuckyLuke Skywalker Avatar answered Oct 14 '22 10:10

LuckyLuke Skywalker