先看效果图:
CSS代码:
/*轨道样式*/
.scroll-pane .scroll-bar:horizontal .track,
.scroll-bar:vertical .track{
-fx-background-color: #ffffff;
-fx-border-color:transparent;
-fx-background-radius: 0em;
-fx-border-radius:2em;
}
/*横向滚动条增减按钮样式*/
.scroll-pane .scroll-bar:horizontal .increment-button ,
.scroll-pane .scroll-bar:horizontal .decrement-button {
-fx-background-color:transparent;
-fx-background-radius: 0em;
-fx-padding:0 0 10 0;
}
/*竖向滚动条增减按钮样式*/
.scroll-pane .scroll-bar:vertical .increment-button ,
.scroll-pane .scroll-bar:vertical .decrement-button {
-fx-background-color:transparent;
-fx-background-radius: 0em;
-fx-padding:0 10 0 0;
}
/*增减按钮中图标样式*/
.scroll-pane .scroll-bar .increment-arrow,
.scroll-pane .scroll-bar .decrement-arrow
{
-fx-background-color:transparent;
-fx-shape: " ";
-fx-padding:0;
}
/*滚动条滑块样式*/
.scroll-pane .scroll-bar:horizontal .thumb,
.scroll-pane .scroll-bar:vertical .thumb {
-fx-background-color: #e7e7e7;
-fx-background-insets: 2, 0, 0;
-fx-background-radius: 2em;
}
直接复制到你的css里,再在fxml文件中引入此css文件即可。
stylesheets="@../css/ScrollPane.css"
<ScrollPane style="-fx-background-color: null;"/>
直接复制就能用,没有效果你来砍我