如何删除Java FX手风琴默认边框?
我有一个简单的表单,有两个元素的手风琴容器。如何删除Java FX手风琴默认边框?,java,javafx,border,accordion,javafx-css,Java,Javafx,Border,Accordion,Javafx Css,我有一个简单的表单,有两个元素的手风琴容器。 我想删除或修改手风琴默认边框 我的FXMLDocument.fxml文件: <AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" styleClass="form" stylesheets="@styles.css" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/10.0.1"&g
我想删除或修改手风琴默认边框 我的
FXMLDocument.fxml
文件:
<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" styleClass="form" stylesheets="@styles.css" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/10.0.1">
<children>
<Accordion layoutX="100.0" layoutY="75.0" prefHeight="250.0" prefWidth="400.0">
<panes>
<TitledPane styleClass="acc-titled-pane" text="Option 1">
<content>
<AnchorPane prefHeight="180.0" prefWidth="200.0" styleClass="acc-pane-body">
</AnchorPane>
</content>
</TitledPane>
<TitledPane styleClass="acc-titled-pane" text="Option 2">
<content>
<AnchorPane prefHeight="180.0" prefWidth="200.0" styleClass="acc-pane-body">
</AnchorPane>
</content>
</TitledPane>
</panes>
</Accordion>
</children>
</AnchorPane>
.form {
-fx-background-color: lightgreen;
}
.acc-titled-pane {
-fx-border-color: transparent;
}
.acc-pane-body {
-fx-background-color: lightgreen;
-fx-border-color: transparent;
}
如您所见,我使所有边界都透明,但仍有一些边界:
我尝试了很多css规则,但没有一个对我有效。首先,你应该为TitledPane()的
.content
子类设置样式
此外,您应该设置-fx边框宽度
,而不是-fx边框颜色
,因为即使是透明的也会导致父级背景透过:
如果将内容子类的边框宽度设置为0
,应该可以解决您的问题:
.acc-titled-pane .content {
-fx-border-width: 0;
}
结果将是: