JavaFX和CSS与继承结合使用时遇到问题。我像这样对通用对话框窗格进行样式设置。每个dialogPane都在标题区域包含此特定的背景图像。
.dialog-pane {
-fx-background-color: #F3F0E5;
}
/**Customization of DialogPane Header**/
.dialog-pane:header .header-panel {
-fx-background-image: url('/splitCards/nobleGuardTop.png');
-fx-background-size: cover;
}
但是现在我希望在程序中具有不同样式的窗口。每个窗口的顶部区域应具有其各自的背景图像。因此,我尝试使用dialogPane.setId("millerBrewer");
为不同的dialogPanes提供单独的ID。
接下来,我想在CSS中解决此特定元素,并在标题中提供他自己的背景图片。当我在我的css文件中写入以下内容时,它适用于正文中的内容:
#millerBrewer{
-fx-background-image: url('/splitCards/majesty_icon.png');
-fx-background-color: #C7EADB;
}
这将更改此特定元素的对话框窗格的内容区域。但是我想访问对话框窗格的标题并在那里更改图像。我尝试使用以下代码:
#millerBrewer .dialog-pane:header .header-panel {
//...specific background image here
}
还有这个:
#millerBrewer .dialog-pane .dialog-pane:header .header-panel {
//...specific background image here
}
我认为我搞砸了继承,但是我不知道如何正确继承。
感谢您的帮助!