Это мой код:
Код: Выделить всё
public class NewMain extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
var textButton = new Button("SomeText");
var fontIcon = new Label("A");
fontIcon.getStyleClass().add("my-icon");
var textAndIconButton = new Button("SomeText", fontIcon);
textAndIconButton.getStyleClass().add("icon-button");
var toolBar = new ToolBar(textButton, textAndIconButton);
toolBar.setMinHeight(40);
var root = new VBox(toolBar);
var scene = new Scene(root, 400, 200);
scene.getStylesheets().add(NewMain.class.getResource("style.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
}
}
Код: Выделить всё
.root {
-fx-font-size:16px;
}
.button {
-fx-padding: 0.4em;
-fx-font-size: 1em;
}
.my-icon {
-fx-font-size: 1.4em;
}
.icon-button {
-fx-padding: 0.2em 0.4em 0.2em 0.4em;
}
[img]https://i.sstatic.net /f5GG0NL6.png[/img]
Как видите, их высоты не равны. Может ли кто-нибудь сказать, как это сделать с помощью CSS?
Подробнее здесь: https://stackoverflow.com/questions/793 ... -in-javafx
Мобильная версия