如何通过css自定义javafx滚动条拇指厚度?

前端之家收集整理的这篇文章主要介绍了如何通过css自定义javafx滚动条拇指厚度?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我尝试通过-fx-pref-height设置厚度:10px;当取向是水平的,并且-fx-pref-width:10px;滚动条方向垂直时.但是不起作用.
  1. .scroll-bar:horizontal .thumb {
  2. -fx-background-color: derive(black,90%);
  3. -fx-background-insets: 2,0;
  4. -fx-background-radius: 0em;
  5. -fx-pref-height: 10px;
  6. }
  7.  
  8. .scroll-bar:vertical .thumb {
  9. -fx-background-color: derive(black,0;
  10. -fx-background-radius: 0em;
  11. -fx-pref-width: 10px;
  12. }

如何通过自定义css实现这一目标?

解决方法

您可以设置滚动条的填充以缩小拇指的厚度.
  1. .scroll-bar:vertical {
  2. -fx-pref-width: 16.5;
  3. -fx-padding: 3;
  4. }
  5.  
  6. .scroll-bar:horizontal {
  7. -fx-pref-height: 16.5;
  8. -fx-padding: 3;
  9. }
  10.  
  11. .scroll-bar,.scroll-bar:pressed,.scroll-bar:focused {
  12. -fx-font-size: 15;
  13. }

猜你在找的CSS相关文章