2

How can I add custom css properties like -fx-accent or -fx-base.

I've tried a naive way:

.root {
    -fx-small: 20;
}

.button {
    -fx-font-size: -fx-small;
}

Unfortunaly, I've got:

WARNING: com.sun.javafx.css.parser.CSSParser declaration CSS Error parsing file:/home/ark/Projects/FXTest/out/production/FXTest/a.css: Expected '< number>' while parsing '-fx-font-size' at [6,15]

3
  • Are you trying to create a variable -fx-small that equals 20? You may consider looking into LESS instead of CSS. It allows for variable declaration so you could do this. Commented Nov 27, 2013 at 20:08
  • Maybe, but I'm looking for the way javafx handle it. I need to find out how -fx-accent property is set in caspian.css. Commented Nov 27, 2013 at 20:38
  • Related question says only colors are allowed as variables in css. Use something like LESS as mentioned Commented Nov 28, 2013 at 14:31

2 Answers 2

0

I never use the -fx prefix for global definitions. For me it is working like it is shown on slide 32: http://de.slideshare.net/ClaudineZillmann/lets-get-wetbestpracticesforskinningjavafxcontrols

Maybe there is a bug with the number format. Have you tried 20.0 ?

Sign up to request clarification or add additional context in comments.

Comments

0

The JavaFX custom CSS-Variables does not support numbers!
You can just define custom colors.

.root {
    -fx-color: red;
}

.button {
    -fx-background-color: -fx-color;
}

Sry bro, maybe in a future release..
Happy coding,
Kalasch

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.