Change size of scrollbar thumb with CSS

后端 未结 8 567
旧巷少年郎
旧巷少年郎 2020-12-30 03:21

I want to get a scrollbar with a thumb larger than the track. I can change the color, the opacity, everything, but I don\'t know how to change the size of the thumbs and the

8条回答
  •  青春惊慌失措
    2020-12-30 04:14

    This is a really old post, but I have a working solution that does 'EXACTLY' what was asked for. Also, this will come in handy for anybody else needing this solution.

    Fiddle

    /* SCROLLBAR */
    /* Let's get this party started */
    ::-webkit-scrollbar {
        width: 10px;
    }
    
    /* Track */
    ::-webkit-scrollbar-track {
        background: rgb(0,0,0);
        border: 4px solid transparent;
        background-clip: content-box;   /* THIS IS IMPORTANT */
    }
    
    /* Handle */
    ::-webkit-scrollbar-thumb {
        background: rgb(25,25,25);
        border: 1px solid rgb(0,0,0);
    }
    

    It is very important to set background-clip: content-box for this to work. You will be left with a track that is thinner than the scroll-bar-thumb. Cheers!!

提交回复
热议问题