我刚接触过高岭土和TornadoFX,目前正在试验它的一些特性。我想使用JFoenix-图书馆并使用TornadoFX的类型安全CSS特性对其控件进行样式设置。但是我不知道如何修改JFoenix控件的CSS类的样式。
例如,JFXDecorator具有默认的CSS类jfx-decorator。要更改标题栏的背景色,我必须修改类jfx-decorator-buttons-container。我怎样才能用TornadoFX做到这一点呢?在.css文件中,我只需要使用
.jfx-decorator-buttons-container {
-fx-background-color: red;
}这与TornadoFX是可能的吗?
发布于 2017-05-20 07:09:55
您提到了类jfx-decorator和jfx-decorator-buttons-container,但是您的示例CSS使用了类jfx-decorator-buttons和container。我不确定您真正需要哪些类,但我将添加后两个类,因为这将从您的示例中生成CSS。
class Styles : Stylesheet() {
companion object {
val jfxDecoratorButtons by cssclass()
val container by cssclass()
}
init {
jfxDecoratorButtons and container {
backgroundColor += Color.RED
}
}
}UPDATE:您更改了问题中的代码,下面是将产生该输出的更新版本:
class Styles : Stylesheet() {
companion object {
val jfxDecoratorButtonsContainer by cssclass()
}
init {
jfxDecoratorButtonsContainer {
backgroundColor += Color.RED
}
}
}用连字符将骆驼大小写的选择器自动转换为下大小写。还可以在cssclass委托函数中指定确切的名称:
val myCssClass by cssclass("my-slightly-different-css-class")
还请注意,由于backgroundColor属性接受多个值,所以必须使用+=将颜色“添加”到颜色列表中。这是所有接受多个值的属性的通用模式。
https://stackoverflow.com/questions/44082894
复制相似问题