Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use transition on ::-webkit-scrollbar?

is it possible to use transitions on webkit scrollbars? I tried:

div#main::-webkit-scrollbar-thumb {     background: rgba(255,204,102,0.25);     -webkit-transition: background 1s;     transition: background 1s; }  div#main:hover::-webkit-scrollbar-thumb {     background: rgba(255,204,102,1); } 

but it isn't working. Or is it possible to create a similar effect (without javascript)?

Here is a jsfiddle showing the rgba transition problem

like image 307
Busti Avatar asked Oct 07 '13 16:10

Busti


People also ask

How do you use Webkit 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.

What is the use of Webkit transition in CSS?

The -webkit-transition Boolean non-standardCSS media feature is a WebKit extension whose value is true if the browsing context supports CSS transitions. Apple has a description in Safari CSS Reference; this is now called transition there.

What is HTML ::- webkit scrollbar?

::-webkit-scrollbar-corner — the bottom corner of the scrollbar, where both horizontal and vertical scrollbars meet. This is often the bottom-right corner of the browser window.


2 Answers

It is fairly easy to achieve using Mari M's background-color: inherit; technique in addition with -webkit-background-clip: text;.

Live demo; https://jsfiddle.net/s10f04du/

@media screen and (-webkit-min-device-pixel-ratio:0) {    .container {     overflow-y: scroll;     overflow-x: hidden;     background-color: rgba(0,0,0,0);     -webkit-background-clip: text;     transition: background-color .8s;   }   .container:hover {     background-color: rgba(0,0,0,0.18);     }   .container::-webkit-scrollbar-thumb {     background-color: inherit;   } } 
like image 74
brillout Avatar answered Sep 20 '22 13:09

brillout


Here's another idea based on replies here. You can use color instead of background-color and then box-shadow to colorize the thumb. You can use -webkit-text-fill-color to color back the text:

https://codepen.io/waterplea/pen/dVMopv

*::-webkit-scrollbar-thumb {           box-shadow: inset 0 0 0 10px; }  div {   overflow: auto;   -webkit-text-fill-color: black;   color: rgba(0, 0, 0, 0);   transition: color .3s ease; }  div:hover {   color: rgba(0, 0, 0, 0.3); } 
like image 31
waterplea Avatar answered Sep 21 '22 13:09

waterplea