📎 Webclip
Styling scrollbars with CSS
The page explains that styled scrollbars are still uncommon, but they can improve a design. It recommends using both the newer scrollbar properties and the WebKit pseudo-elements so the result works in more browsers.
Reading notes#
- The article says scrollbars have traditionally been hard to style, but CSS now includes
scrollbar-colorandscrollbar-width. - It defines CSS variables for scrollbar width, background color, and thumb color so the values can be reused.
- It uses
scrollbar-widthandscrollbar-coloron the container as the newer scrollbar styling approach. - It notes that Chrome support needs settings enabled, and Firefox needs
layout.css.scrollbar-color.enabledset totrue. - It says
scrollbar-colortakes thumb color first and background second, and thatdarkandlightare not supported by browsers yet. - It uses
::-webkit-scrollbarto set the width,::-webkit-scrollbar-trackfor the track background, and::-webkit-scrollbar-thumbfor the thumb styling. - It says the WebKit prefix is more widely supported, so combining it with the newer properties gives broader browser coverage.
