JavaFXCSS:如何从其他CSS设置继承背景色?

JavaFXCSS:如何从其他CSS设置继承背景色?,java,css,javafx,background-color,Java,Css,Javafx,Background Color,我有一个CSS文件可以在JavaFXTabPane和Tab中设置样式 有没有办法设置选项卡窗格的背景色并继承选项卡的背景色 如果我设置了选项卡内容区域背景色,我可以在没有再次指定颜色的情况下为选项卡选择此背景色吗 .tab-content-area { -fx-background-color: #d9d9d9; /* I want to apply this color to tab background */ } .tab:selected { -fx-background-

我有一个CSS文件可以在JavaFX
TabPane
Tab
中设置样式

有没有办法设置
选项卡窗格的背景色并继承
选项卡的背景色

如果我设置了
选项卡内容区域
背景色,我可以在没有再次指定颜色的情况下为选项卡选择此背景色吗

.tab-content-area 
{
  -fx-background-color: #d9d9d9; /* I want to apply this color to tab background */ 
}

.tab:selected 
{
  -fx-background-color : -fx-something; <?? what do i put here??>
  -fx-background-insets: 0, 1 1 0 1;
  -fx-background-radius: 5 5 0 0, 4 4 0 0;
}
.tab内容区
{
-fx背景色:#d9d9d9;/*我想将此颜色应用于选项卡背景*/
}
.选项卡:已选定
{
-fx背景色:-fx某物;
-外汇背景插图:0,1 0 1;
-外汇背景半径:5 5 0 0,4 4 0 0;
}

您可以设置
选项卡的背景
透明
继承

.tab-content-area {
   -fx-background-color: #d9d9d9; /* I want to apply this color to tab background */ 
}

.tab:selected {
  -fx-background-color : transparent; /* Or: -fx-background-color : inherit;*/
  -fx-background-insets: 0, 1 1 0 1;
  -fx-background-radius: 5 5 0 0, 4 4 0 0;
}
您可以检查
选项卡窗格
的CSS结构

要了解有关JavaFX中命名颜色的更多信息,请参阅


可以找到
inherit
的文档。

我做了更多的挖掘,找到了问题的答案,这使我能够创建一个足够好的解决方案来满足我的需要

我的css现在看起来像这样:

* {
    -fx-my-global-color:#d9d9d9;
  }
.tab-content-area 
  {
  -fx-background-color: -fx-my-global-color;  
  }

.tab:selected 
 {
  -fx-background-color : -fx-my-global-color;
  -fx-background-insets: 0, 1 1 0 1;
  -fx-background-radius: 5 5 0 0, 4 4 0 0;
 }