【发布时间】:2017-11-09 17:50:08
【问题描述】:
我在父布局 BorderPane 的左侧使用了一个 VBox。我想使用一个 css 文件来更改和使用包含我的 VBox 的 BorderPane 左侧的图像背景。我的 ccs 文件中有以下内容,但无法使其正常工作。
.vbox{
-fx-background-image: url("/ui/image11.jpg");
-fx-background-repeat: no-repeat;
-fx-background-position: center center;
-fx-background-size: 500 500;
}
.root{
-fx-background-color: #ecf0f1;
-fx-background-position: center center;
-fx-background-size: 500 500;
}
.button{
-fx-text-fill: #ecf0f1;
-fx-background-color: #455d7a;
-fx-position: center;
-fx-min-width: 150px;
-fx-transition-duration: 1;
}
有了这个 css 文件,.root 和 .button 中的规则确实适用,但不适用于 .vbox。如何管理 BorderPane 中不同部分的背景。
我使用以下代码行导入 css 文件:
scene.getStylesheets().add(this.getClass().getResource("/styles/contentStyle.css").toExternalForm());
这是正确的方法吗? css 文件在另一个包中。
【问题讨论】: