JavaFX 滑块:轨道长度?勾选标签颜色?

2022-01-24 00:00:00 slider css java javafx javafx-8

.slider .track {-fx-pref-宽度:300px;}.slider .axis-tick-label {-fx-文本填充:白色;}

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

解决方案

可以通过设置 slider-fx-pref-width 属性并设置.slider .axis-fx-tick-label-fill属性:

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

<上一页>

<小时>

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

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

.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?

解决方案

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

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


                     


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

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

相关文章