I tried to set thickness by -fx-pref-height: 10px;
when orientation is horizontal, and by -fx-pref-width: 10px;
when scrollbar orientation is vertical. But is doesn't work.
.scroll-bar:horizontal .thumb {
-fx-background-color: derive(black, 90%);
-fx-background-insets: 2, 0, 0;
-fx-background-radius: 0em;
-fx-pref-height: 10px;
}
.scroll-bar:vertical .thumb {
-fx-background-color: derive(black, 90%);
-fx-background-insets: 2, 0, 0;
-fx-background-radius: 0em;
-fx-pref-width: 10px;
}
How to achieve this by customizing css?
Double-click/tap on ScrollHeight. The Edit String window will open with the default value of -255. That is the standard size of the scrollbars you see on Windows. To change the Scrollbars height to your liking, enter a value between -120 (smaller) to -1500 (larger) for the size you want, and click/tap on OK.
The scrollbar width First, we need to define the size of the scrollbar. This can be the width for vertical scrollbars, and the height for horizontal ones. With that set, we can style the scrollbar itself.
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.
you can set the padding of the scrollbars to shrink the thumbs' thickness.
.scroll-bar:vertical {
-fx-pref-width: 16.5;
-fx-padding: 3;
}
.scroll-bar:horizontal {
-fx-pref-height: 16.5;
-fx-padding: 3;
}
.scroll-bar, .scroll-bar:pressed, .scroll-bar:focused {
-fx-font-size: 15;
}
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