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
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.
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.
::-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.
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; } }
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); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With