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.
a box or “thumb” within a scrollbar that allows the user to move to a specific region by dragging the box to the appropriate location within the scrollbar. Also called a “scrollbox” or “elevator”.
To get the height of the scroll bar the offsetHeight of div is subtracted from the clientHeight of div. OffsetHeight = Height of an element + Scrollbar Height. ClientHeight = Height of an element. Height of scrollbar = offsetHeight – clientHeight.
We can use the CSS “::-webkit-scrollbar” property which is responsible for changing the shape, color, size, shade, shadow, etc. of the scroll bar. But, here the property which we will use is the direction property of CSS for changing the position of the scroll bar.
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 */ }
Source
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;
}
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.
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