JavaFX CSS按钮图形调整大小 [英] Javafx css button graphic resize
问题描述
我想更改按钮内图标的大小. 图像的尺寸为512 x 512,我想将尺寸调整为16x16. 因此,使用javaFX CSS实现此目标的最佳方法是什么.
I want to change the size of an icon inside a button. The image has a size of 512 x 512, i want to resize to 16x16. So, what's the best way to acheive this using javaFX CSS.
这是到目前为止我要做的事情:
Here is what i'm done until now :
#btnCancel.button {
-fx-graphic: url("/img/close.png") ;
-fx-graphic-size:16px 16px ; ( I think this property not exist in javafx css)
}
但这对我不起作用.
推荐答案
我不知道可以直接用于设置-fx-graphic
大小的任何 css属性,但是您可以实现使用-fx-background-image
属性获得相似的结果.这将允许您使用-fx-background-size
设置宽度和高度值.
I am not aware of any css property that can be used directly to set the -fx-graphic
's size but you can achieve similar results using -fx-background-image
property. This will allow you to set width and height values using -fx-background-size
.
您可以从查看实际情况
使用-fx-graphic
将-fx-background-image
与-fx-background-size
一起使用
这篇关于JavaFX CSS按钮图形调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!