我想用CSS定制一个滚动条
我使用这个WebKit CSS代码,它适用于Safari和Chrome:
::-webkit滚动条{
宽度:15px;
高度:15px;
}
:-webkit滚动条轨迹条{
背景色:#c2d2e4;
}
:-webkit滚动条拇指:垂直{
高度:30px;
背景色:#0a4c95;
}
我如何在Firefox中做同样的事情
我知道我可以很容易地使用jQuery来实现,但如果可行的话,我更愿意使用纯CSS
如果有人提出专家建议,我将不胜感激
截至2018年底,Firefox的定制功能有限
请参见以下答案:
- https://stackoverflow.com/a/54101063/405015
- https://stackoverflow.com/a/53739309/405015
以下是背景信息:https://bugzilla.mozilla.org/show_bug.cgi?id=1460109
没有Firefox可以与:-webkit scrollbar
和friends相提并论
您必须坚持使用JavaScript。
很多人都喜欢此功能,请参见:https://bugzilla.mozilla.org/show_bug.cgi?id=77790
就JavaScript替换而言,您可以尝试:
- https://github.com/mdbootstrap/perfect-scrollbar
- https://github.com/Grsmto/simplebar
- https://github.com/vitch/jScrollPane