Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the scrollbar color using css [duplicate]

Tags:

css

My jsfiddle is here
I trying to change the color of the scrollbar but here it is not working.

Css:

.flexcroll {          scrollbar-face-color: #367CD2;     scrollbar-shadow-color: #FFFFFF;     scrollbar-highlight-color: #FFFFFF;     scrollbar-3dlight-color: #FFFFFF;     scrollbar-darkshadow-color: #FFFFFF;     scrollbar-track-color: #FFFFFF;     scrollbar-arrow-color: #FFFFFF; }​ 
like image 626
Suresh Pattu Avatar asked Sep 06 '12 05:09

Suresh Pattu


People also ask

Can we change color of scrollbar in CSS?

color: It is used to set the scrollbar color to any custom color. It takes two values, the first is applied to the scrollbar thumb and the second color is applied to the scrollbar track. red green scrollbar-color.

Can you style the scroll bar CSS?

As of 2020, 96% of internet users are running browsers that support CSS scrollbar styling. However, you will need to write two sets of CSS rules to cover Blink and WebKit and also Firefox browsers. In this tutorial, you will learn how to use CSS to customize scrollbars to support modern browsers.

How do I customize my vertical scrollbar?

Scrollbar Selectors For webkit browsers, you can use the following pseudo elements to customize the browser's scrollbar: ::-webkit-scrollbar the scrollbar. ::-webkit-scrollbar-button the buttons on the scrollbar (arrows pointing upwards and downwards). ::-webkit-scrollbar-thumb the draggable scrolling handle.

How do I change the scrollbar color in Chrome?

Left-click and drag the small circle on the Scrollbar thumb color palette to select a color there. You can also choose different shades for your selected color by dragging the HSV bar sliders up and down. Drag the circle within the Scrollbar track color palette to choose a color for the track bar.


2 Answers

You can use the following attributes for webkit, which reach into the shadow DOM:

::-webkit-scrollbar              { /* 1 */ } ::-webkit-scrollbar-button       { /* 2 */ } ::-webkit-scrollbar-track        { /* 3 */ } ::-webkit-scrollbar-track-piece  { /* 4 */ } ::-webkit-scrollbar-thumb        { /* 5 */ } ::-webkit-scrollbar-corner       { /* 6 */ } ::-webkit-resizer                { /* 7 */ } 

Here's a working fiddle with a red scrollbar, based on code from this page explaining the issues.

http://jsfiddle.net/hmartiro/Xck2A/1/

Using this and your solution, you can handle all browsers except Firefox, which at this point I think still requires a javascript solution.

like image 186
Hayk Martiros Avatar answered Oct 06 '22 17:10

Hayk Martiros


Your css will only work in IE browser. And the css suggessted by hayk.mart will olny work in webkit browsers. And by using different css hacks you can't style your browsers scroll bars with a same result.

So, it is better to use a jQuery/Javascript plugin to achieve a cross browser solution with a same result.

Solution:

By Using jScrollPane a jQuery plugin, you can achieve a cross browser solution

See This Demo

like image 22
Ahsan Khurshid Avatar answered Oct 06 '22 16:10

Ahsan Khurshid