我对 JavaFX 上下文中的 CSS 了解不多。 我正在尝试访问某些 TitledPanes 的标签,以便我可以在标签旁边放置一个简单的图像,但我不知道这样做的正确语法是什么。
我试过:
.TitledPane > .title > .text { //TitledPane is the CSS class I assign to my Title Panes.
/*CSS Code Here*/
}
那没用。
.TitledPane > .title { } //This only affects the background, I would like the graphic to be side-by-side with the actual text.
.TitlePane LabeledText { } //This worked with Buttons so I thought it might work with TitledPane. I was wrong.
我需要使用什么来访问 Label 才能使用 CSS 设置样式?
最佳答案
CSS documentation for TitledPane
似乎是错误的:如前所述,标题中的 text
类实际解析为 Text
对象,而不是 Label
。当然,Text
不支持 -fx-graphic
css 属性。
幸运的是,由于 TitledPane
扩展了 Labeled
,您可以直接使用 Labeled
中定义的属性:
.TitledPane {
-fx-graphic: url(path/to/image/file) ;
}
关于java - 我需要使用什么 CSS 语法来访问 JavaFX 中 TitledPane 的标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26283633/