1

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.

1 Answer 1

2

Have you tried with capital letters?

HBox {
  -fx-spacing:10px;
}
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, that works. Whereabouts is that in the CSS reference?
docs.oracle.com/javafx/2/api/javafx/scene/doc-files/cssref.html "JavaFX CSS also has some extensions to CSS in support of specific JavaFX features" if it answer you question, mark it as correct answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.