java 删除 JFX 中选项卡后面的灰色 bg
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10609103/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Remove gray bg behind the tabs in JFX
提问by 4lex1v
So is there any way to remove the gray area behind the tab(s):
那么有什么方法可以删除选项卡后面的灰色区域:
I've tried to do this with CSS, but didn't find how.
我试图用 CSS 来做到这一点,但没有找到方法。
采纳答案by Uluk Biy
JavaFX has a built-in default CSS sheet named caspian.css. Please read this post: https://stackoverflow.com/a/10149050/682495.
To change the default CSS, add this selector to your CSS file and customize it:
JavaFX 有一个名为 caspian.css 的内置默认 CSS 表。请阅读这篇文章:https: //stackoverflow.com/a/10149050/682495。
要更改默认 CSS,请将此选择器添加到您的 CSS 文件并对其进行自定义:
.tab-pane *.tab-header-background {
-fx-background-color: -fx-outer-border, -fx-inner-border, derive(-fx-color, -20%);
-fx-effect: innershadow(two-pass-box , rgba(0,0,0,0.6) , 4, 0.0 , 0 , 0);
}
回答by user2229691
To set the background color of the tabpane header write in the CSS file:
要设置标签页标题的背景颜色,请在 CSS 文件中写入:
.tab-pane .tab-header-area .tab-header-background {
-fx-background-color: yellow;
}
To remove the borders write:
要删除边框,请写入:
.tab-pane .tab-header-area .tab-header-background {
-fx-effect: null;
}
To remove the header completely set opacity to 0:
要完全删除标题,请将不透明度设置为 0:
.tab-pane .tab-header-area .tab-header-background {
-fx-opacity: 0;
}
More on style class tab-pane you can find here:
http://docs.oracle.com/javafx/2/api/javafx/scene/doc-files/cssref.html#tabpane
您可以在此处找到有关样式类选项卡窗格的更多信息:http:
//docs.oracle.com/javafx/2/api/javafx/scene/doc-files/cssref.html#tabpane
回答by yasin
Here is an easier way tabPane.getStyleClass().add("floating"); (copied from a comment above that didn't get enough attention)
这是一个更简单的方法 tabPane.getStyleClass().add("floating"); (从上面没有得到足够关注的评论中复制)