How to refer to an anchor pane in css?

user3435407 picture user3435407 · Feb 26, 2015 · Viewed 8.3k times · Source

is there a possibility to refer to an anchor pane in css?

If the anchor pane happens to be the root, than it's ok:

.root{
-fx-background-image: url("xxx.yy");
}

It works. But if not, then how to do this? I tried .anchor-pane{}, it didn't work. Then I read, that anchor pane has everything that Pane has. So I tried .pane{} too... It didn't work.

How can I set the background to a none root anchor pane? Thank you!

Answer

ItachiUchiha picture ItachiUchiha · Feb 26, 2015

You can always assign a css class and add it to the AnchorPane explicitly

anchorPane.getStyleClass().add("pane");

In your css :

.pane{
    -fx-background-image: url("xxx.yy");
}

You can perform the same by adding a css id

anchorPane.setId("pane");

In you css :

#pane{
    -fx-background-image: url("xxx.yy");
}