如何通过css自定义javafx滚动条拇指厚度?

Van*_*ard 6 css javafx scrollbar

我尝试-fx-pref-height: 10px;在方向为水平时设置厚度,并-fx-pref-width: 10px;在滚动条方向为垂直时设置厚度.但是不起作用.

.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;
}
Run Code Online (Sandbox Code Playgroud)

如何通过自定义css实现这一目标?

Pak*_*ert 7

您可以设置滚动条的填充以缩小拇指的厚度.

.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;
}
Run Code Online (Sandbox Code Playgroud)