I styled my vertical scrollbars with the following code:
::-webkit-scrollbar { width: 4px; border: 1px solid #d5d5d5; } ::-webkit-scrollbar-track { border-radius: 0; background: #eeeeee; } ::-webkit-scrollbar-thumb { border-radius: 0; background: #b0b0b0; }
Now, my vertical scrollbar looks like this:
However, my horizontal scrollbar looks like this :
How can I set a 2-4px height for it?
For horizontal scrollable bar use the x and y-axis. Set the overflow-y: hidden; and overflow-x: auto; that will automatically hide the vertical scroll bar and present only the horizontal scrollbar. The white-space: nowrap; property is used to wrap text in a single line.
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.
As of 2020, 96% of internet users are running browsers that support CSS scrollbar styling. However, you will need to write two sets of CSS rules to cover Blink and WebKit and also Firefox browsers. In this tutorial, you will learn how to use CSS to customize scrollbars to support modern browsers.
::-webkit-scrollbar { height: 4px; /* height of horizontal scrollbar ← You're missing this */ width: 4px; /* width of vertical scrollbar */ border: 1px solid #d5d5d5; }
since logically one cannot force a vertical scrollbar to be a certain height (since dictated by the positioned parent) - therefore such height
property is to target the horizontal's scrollbar height - and vice-versa (width
for the width of the vertical scrollbar.).
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