我有这样的代码:文本的CSS样式没有出现白色
private void createAndAddCommonInformationSection(){
Text text = new Text("CommonText");
gridPane.add(header);
}
的应该会出现在白色的颜色,所以我有一个CCS文件如下:
.root {
-fx-base: rgb(50, 50, 50);
-fx-background: rgb(50, 50, 50);
-fx-control-inner-background: rgb(50, 50, 50);
}
.tab {
-fx-background-color: linear-gradient(to top, -fx-base, derive(-fx-base,30%));
}
.menu-bar {
-fx-background-color: linear-gradient(to bottom, -fx-base, derive(-fx-base,30%));
}
.tool-bar:horizontal {
-fx-background-color:
linear-gradient(to bottom, derive(-fx-base,+50%), derive(-fx-base,-40%), derive(-fx-base,-20%));
}
.button {
-fx-background-color: transparent;
}
.button:hover {
-fx-background-color: -fx-shadow-highlight-color, -fx-outer-border, -fx-inner-border, -fx-body-color;
-fx-color: -fx-hover-base;
}
.table-view {
-fx-table-cell-border-color:derive(-fx-base,+10%);
-fx-table-header-border-color:derive(-fx-base,+20%);
}
.split-pane:horizontal > * > .split-pane-divider {
-fx-border-color: transparent -fx-base transparent -fx-base;
-fx-background-color: transparent, derive(-fx-base,20%);
-fx-background-insets: 0, 0 1 0 1;
}
.my-gridpane {
-fx-background-color: radial-gradient(radius 100%, derive(-fx-base,20%), derive(-fx-base,-20%));
}
.separator-label {
-fx-text-fill: orange;
}
.text{
-fx-text-fill: white;
}
一切都很是使用CSS文件工作正常,除了我的代码段中的文本颜色不会以预期的颜色显示。
我已经尝试
-fx-fill: white;
和
-fx-fill-text: white;
,但没有什么帮助。
我在做什么错?
@Rinin猜测这与问题中的'javafx'有关。 – sevenseacat
@Rounin阅读[文档](http://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html#intronaming):“命名惯例已经建立用于派生JavaFX类名称中的CSS样式类名称以及从JavaFX变量名称派生CSS属性名称......将JavaFX变量名称映射到CSS属性名称的约定与添加'-fx-'前缀相似。 “ –