java JavaFX 滚动窗格样式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41804373/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JavaFX ScrollPane styling
提问by Philipp Brucker
I'm trying to create a black and white ScrollPane in JavaFX. I already created a CSS file, wich works pretty fine. Except for this little square:
我正在尝试在 JavaFX 中创建一个黑白 ScrollPane。我已经创建了一个 CSS 文件,效果很好。除了这个小广场:
Whatever I try, I'm not able to turn it black. Here is my CSS file:
无论我尝试什么,我都无法将其变黑。这是我的 CSS 文件:
.scroll-pane {
-fx-background-color: black;
}
.scroll-bar:horizontal, .scroll-bar:vertical{
-fx-background-color:transparent;
}
.increment-button, .decrement-button {
-fx-background-color: transparent;
-fx-border-color: transparent;
}
.scroll-bar:horizontal .track,
.scroll-bar:vertical .track{
-fx-background-color: transparent;
-fx-border-color: transparent;
-fx-background-radius: 0em;
}
.scroll-bar:horizontal .thumb,
.scroll-bar:vertical .thumb {
-fx-background-color: white;
-fx-background-radius: 5em;
}
Is there a way to change the colour of this square? Thank you in advance!
有没有办法改变这个方块的颜色?先感谢您!
回答by DVarga
Simply add the following selector using the needed color:
只需使用所需的颜色添加以下选择器:
.scroll-pane > .corner {
-fx-background-color: black;
}
回答by MBec
Use "corner" class.
使用“角落”类。
.scroll-pane > .corner {
-fx-background-color: black;
}