use transition on ::-webkit-scrollbar?

后端 未结 5 705
野的像风
野的像风 2021-02-02 09:06

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

div#main::-webkit-scrollbar-thumb {
    background: rgba(255,204,102,0.25);
    -webkit-transiti         


        
5条回答
  •  悲哀的现实
    2021-02-02 09:36

    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 even hack text-shadow for fun like I did, obviously not a production-ready approach but you can just override color in child container):

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

    *::-webkit-scrollbar-thumb {        
      box-shadow: inset 0 0 0 10px;
    }
    
    div {
      overflow: auto;
      color: rgba(0, 0, 0, 0);
      transition: color .3s ease;
    }
    
    div:hover {
      color: rgba(0, 0, 0, 0.3);
    }
    

提交回复
热议问题