How to style a scrollbar by using only CSS features and have a cross browser support
For your new web application, you might want to style the scrollbar so that it fits to the general design.
You can either use JavaScript code to achieve the styling or you could stick to CSS properties and pseudo-selectors.
In this article we pick the second variant and our main goal is to have a cross browser support for a styled scrollbar.
For Chrome, Safari and Opera browsers we can use the -webkit-scrollbar CSS selector and its sub selectors. Lets assume that we have a list with the ID #countries which contains a set of countries. The following code has comments about which part of the scrollbar each pseudo-element styles:
As you saw we can change the design of the scrollbar completely, starting from setting widths or background colors up to changing the icons for the up & down buttons.
The previous selectors are not supported from the Internet Explorer browser. IE supports a non standard set of CSS properties, which work only with this browser. Unfortunately with this properties we can only change the colors of the scrollbar.
Using the previous code snippets you styled the scrollbar in Crome, Safari, Opera and Internet Explorer. Unfortunately Firefox supports no CSS styling.