14

Is the height of scroll thumb set as default according to scroll-able area? If not, can I set scrollbar thumb height? If it is possible how? I tried to do it the following way.

body::-webkit-scrollbar-thumb {
  background-color: darkgrey;
  outline: 1px solid slategrey;
  height: 5px;
}

But it have no impact on the page. Please help. Thanks in advance.

AngularDoubts
  • 459
  • 2
  • 11
  • 30

3 Answers3

30

I don't think so, the height of the thumb is based in the size of content, you can change the width inside the ::-webkit-scrollbar but the height will always be based on the content.

::-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 */ }

css-tricks

enter image description here

Source

7

If you want to set fixed min height to the scrollbar thumb even when scroll. we can set like below:

::-webkit-scrollbar-thumb {
    min-height: 40px;
   }
  • Unable to set its height – Anjali Sharma Sep 10 '20 at 06:17
  • 3
    @AnjaliSharma you can set min-height but not height. scrollbar adjusts its height by data. so if a lot of data then you'll see a small scrollbar else if data increases height decreases. – Bharat chaudhari Oct 20 '20 at 13:18
  • 1
    This is working perfectly fine. Setting min-height will give you desired you want for scrollbar thumb even if you have huge amount of data. It will adjust the content and scrolling speed accordingly. – mrsagar105 May 11 '23 at 11:03
3

You can do this:

::-webkit-scrollbar-thumb{
    background-color: transparent;
    border-top: 60px solid green /*or any height and color you want*/;
}

that will make the height constant with value of 60px, but pay attention that it will not be able scroll to the very end because of the transparent space.

Eliya_101
  • 39
  • 2