JavaFX Slider:跟踪长度?刻度标签颜色?

时间:2022-06-09 16:05:37
.slider .track {
    -fx-pref-width: 300px;
}

.slider .axis-tick-label {
    -fx-text-fill: white;
}

My feeble attempts of writing CSS styles for the slider both don't work. I'm 100% sure my syntax is off. Any help?

我为滑块编写CSS样式的微弱尝试都不起作用。我100%确定我的语法已关闭。有帮助吗?

1 个解决方案

#1


2  

You can do it by setting the -fx-pref-width attribute of slider and setting the -fx-tick-label-fill attribute of .slider .axis:

您可以通过设置滑块的-fx-pref-width属性并设置.slider .axis的-fx-tick-label-fill属性来实现:

.slider { -fx-pref-width: 300px; }
.slider .axis { -fx-tick-label-fill: white; }

                     JavaFX Slider:跟踪长度?刻度标签颜色?

Note: For vertical Slider, to affect the length of the track, you have to use the -fx-pref-height attribute:

注意:对于垂直滑块,要影响轨道的长度,必须使用-fx-pref-height属性:

.slider:vertical { -fx-pref-height:300px; }

#1


2  

You can do it by setting the -fx-pref-width attribute of slider and setting the -fx-tick-label-fill attribute of .slider .axis:

您可以通过设置滑块的-fx-pref-width属性并设置.slider .axis的-fx-tick-label-fill属性来实现:

.slider { -fx-pref-width: 300px; }
.slider .axis { -fx-tick-label-fill: white; }

                     JavaFX Slider:跟踪长度?刻度标签颜色?

Note: For vertical Slider, to affect the length of the track, you have to use the -fx-pref-height attribute:

注意:对于垂直滑块,要影响轨道的长度,必须使用-fx-pref-height属性:

.slider:vertical { -fx-pref-height:300px; }