JavaFX TitledPane 无法覆盖 -fx-text-fill
JavaFX TitledPane can't override -fx-text-fill
我正在尝试更改 TitledPane
的标题颜色,但我无法做到这一点。
这是我的 css:
.titled-pane * {
-fx-background-color: transparent;
}
.titled-pane .title{
-fx-background-color: #666666;
}
.titled-pane .title:hover {
-fx-background-color: #AAAAAA;
}
.titled-pane .title:pressed {
-fx-background-color: #DDDDDD;
-fx-text-fill: black; // does not work
}
后台设置正常,所以我不明白是什么问题。
我看到了 this 个问题,但我不知道如何将解决方案应用到我的案例中。
提前致谢。
如果您查看如何将样式应用到 modena.css 中的 TitledPane
,您会看到文本是在根选择器上设置样式的:
.titled-pane {
-fx-text-fill: -fx-text-base-color;
}
所以你只需要在根按下状态应用所需的文本颜色:
.titled-pane * {
-fx-background-color: transparent;
}
.titled-pane:pressed {
-fx-text-fill: red;
}
.titled-pane .title{
-fx-background-color: #666666;
}
.titled-pane .title:hover {
-fx-background-color: #AAAAAA;
}
.titled-pane .title:pressed {
-fx-background-color: #DDDDDD;
}
我正在尝试更改 TitledPane
的标题颜色,但我无法做到这一点。
这是我的 css:
.titled-pane * {
-fx-background-color: transparent;
}
.titled-pane .title{
-fx-background-color: #666666;
}
.titled-pane .title:hover {
-fx-background-color: #AAAAAA;
}
.titled-pane .title:pressed {
-fx-background-color: #DDDDDD;
-fx-text-fill: black; // does not work
}
后台设置正常,所以我不明白是什么问题。
我看到了 this 个问题,但我不知道如何将解决方案应用到我的案例中。
提前致谢。
如果您查看如何将样式应用到 modena.css 中的 TitledPane
,您会看到文本是在根选择器上设置样式的:
.titled-pane {
-fx-text-fill: -fx-text-base-color;
}
所以你只需要在根按下状态应用所需的文本颜色:
.titled-pane * {
-fx-background-color: transparent;
}
.titled-pane:pressed {
-fx-text-fill: red;
}
.titled-pane .title{
-fx-background-color: #666666;
}
.titled-pane .title:hover {
-fx-background-color: #AAAAAA;
}
.titled-pane .title:pressed {
-fx-background-color: #DDDDDD;
}