javafx的css语法_JavaFX和CSS样式

I'm kind of new to CSS and was wondering if anyone can answer a questions for me.

In a lot of CSS sample code I see sections like this:

.listview{

...

-fx-background-color: -fx-box-border, -fx-control-inner-background ;

...

}

So my question is where do the -fx-box-border, -fx-control-inner-background values come from? They appear to be connstants defined somewhere but where and what are their values?

Thanks in advance.

解决方案

Values such as -fx-background-color are "looked-up colors" defined in the default JavaFX (8) stylesheet, modena.css.

You can find out their values (and many other things) by examining the default stylesheet that ships with your Java Runtime Environment (JRE).

jar xvf $JAVA_HOME/jre/lib/ext/jfxrt.jar com/sun/javafx/scene/control/skin/modena/modena.css

cat com/sun/javafx/scene/control/skin/modena/modena.css

(Adjust the above command for your installed JRE location if JAVA_HOME is not set in your environment).

Definition of a "looked-up-color", copied from the JavaFX CSS reference guide:

With looked-up colors you can refer to any other color property that is set on the current node or any of its parents. This is a very powerful feature, as it allows a generic palette of colors to be specified on the scene then used thoughout the application. If you want to change one of those palette colors you can do so at any level in the scene tree and it will affect that node and all its decendents. Looked-up colors are not looked up until they are applied, so they are live and react to any style changes that might occur, such as replacing a palette color at runtime with the "style" property on a node.

In the following example, all background color of all buttons uses the looked up color "abc".

.root { abc: #f00 }

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值