Transparent scrollbar with css

后端 未结 8 1669
面向向阳花
面向向阳花 2020-12-05 04:15

Now use this code (and many variations of this), but scroll track get dark-grey color, something like #222222 or near this. Find many examples, but all of them give same res

8条回答
  •  余生分开走
    2020-12-05 04:53

    To control the background-color of the scrollbar, you need to target the primary element, instead of -track.

    ::-webkit-scrollbar {
        background-color: blue;
    }
    
    ::-webkit-scrollbar-track {
        -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
    }
    

    I haven't succeeded in rendering it transparent, but I did manage to set its color.

    Since this is limited to webkit, it is still preferable to use JS with a polyfill: CSS customized scroll bar in div

提交回复
热议问题