2

我已经开始将变量分配给我的 JavaFX CSS 中的常用颜色,并引用变量而不是颜色常量:

* {
    theme-backgroundDark: #335588;
}

#messageListPane {
    -fx-background-color: theme-backgroundDark;
}

现在我想把我定义颜色变量名称的块移到一个单独的 .css 文件中。这将允许我在运行时换出不同的 .css 文件来更改应用程序的主题:

Theme1.css

* {
    theme-backgroundDark: #335588;
}

主.css

@import url( "/styles/Theme1.css" );

#messageListPane {
    -fx-background-color: theme-backgroundDark;
}

但是当我这样做时,JavaFX 无法在运行时找到变量:

WARNING: Could not resolve 'theme-backgroundDark' while resolving lookups for '-fx-background-color' from rule '*#messageListPane ' in stylesheet file:/C:/xxxx/styles/Main.css

声明没有问题@import;我还有其他@import定义类选择器的 s,并且在Main.css. 它似乎与通配符选择器有关* { ... }

那么为什么通配符选择器中的命名颜色变量可以在同一个 CSS 中工作,但在从另一个 CSS 导入时却不能呢?

4

1 回答 1

0

The named colors are fine. My @import statement is being ignored, simple as that. If I attach Themes.css manually via code, the named colors are visible. The @import statement is not picking up the themes file and not giving me any type of error. I'll open another question for that.

于 2015-03-18T14:34:18.057 回答