Adam
Adam

Reputation: 36703

JavaFX CSS type based selectors

I'm having difficultly understanding JavaFX CSS type selectors. I've had a good look at the official documentation

If I want to customize the spacing of layout elements such as HBox and VBox using the -fx-spacing rule do I have to add a custom CSS class to them all manually before I can reference them??

hBox.getStyleClass().add("hbox")
vBox.getStyleClass().add("vbox")

There doesn't seem to be a type based selection like this:

hbox {
   -fx-spacing: 5
}

HBox and VBox are documented as "Style class: empty by default" I'm used to HTML where you can select by element type, e.g. div, button etc. I've got a lot of layouts and I don't want to have to go through them all.

Upvotes: 1

Views: 1037

Answers (1)

Benoit
Benoit

Reputation: 208

Have you tried with capital letters?

HBox {
  -fx-spacing:10px;
}

Upvotes: 2

Related Questions