JavaFX: multiple selectors modifying the same property

I have a stylesheet like this:

*
{
    -fx-font-size: 15px;
}

.title
{
    -fx-font-size: 20px;
}

I thought that, since *more general than .title, then -fx-font-size, defined in .title, would have priority over it, but I am mistaken. No matter what font size I changed to .title, this title label still displays in 15px. When I deleted the block *, the title label will correctly display the size defined in .title.

Is there something wrong with my approach? I'm just trying to establish a “global” look and give specific nodes the flexibility to customize when this node needs a more individual look.

Edit

, CSS, . -fx-font-size -fx-border-color , , CSS.

, - .

+4
2

node.

Label ( ), Node, node. node -fx-font-size Label, node, , .

, node title:

* {
    -fx-font-size: 15px;
}

.title * {
    -fx-font-size: 20px;
}
+2

!important:

.title{
    -fx-font-size: 20px !important;
}

, :

#title{
   -fx-font-size: 20px !important;
}

https://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html :

,


CSS . URL-, . , . NodesetStyle API. style = "..." HTML. , , . , . "! important" .


Node

JavaFX node. , :

• ( )

• , API JavaFX

• ( )

, node, , , . .

0

Source: https://habr.com/ru/post/1662590/


All Articles