我正在尝试使用 CSS 在 JavaFX 中的按钮之间添加一些空间。 我知道分隔符元素可以做到这一点,但我更喜欢用它来分隔按钮的逻辑组。
我试过:
<HBox id="buttonPanel" prefHeight="400.0" prefWidth="600.0" styleClass="buttonPanel" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.chart.buttons.ButtonPanelController">
<stylesheets>
<URL value="@buttonpanel.css"/>
</stylesheets>
<Button text="INSTRUMENT"/>
<Separator/>
<Button text="F"/>
<Button text="T"/>
<Button text="SR"/>
<Separator/>
</HBox>
.buttonPanel .button {
-fx-spacing: 5;
-fx-border-width: 0;
-fx-padding: 1 2 1 2; /* Top Right Bottom Left */
}
但我没有得到任何结果:
最佳答案
如果您提供 ID,请尝试 #
#buttonPanel {
-fx-spacing: 5;
-fx-border-width: 0;
-fx-padding: 1 2 1 2; /* Top Right Bottom Left */
}
关于JavaFX - 通过 CSS 在按钮之间添加空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56573278/