在JavaFX中使用CSS样式表对TableView进行样式设置

31

我该如何为我的TableView中的"THIS"点设置样式?

TableView

我的CSS代码如下:

   */*
 * Empty Stylesheet file.
 */

.root{
    -fx-background-color: #262626;
}

.table-view{
   -fx-background-color: transparent;
}

.table-view:focused{
    -fx-background-color: transparent;
}

/* Spaltenköpfe
    Struktur column-header-background -> column-header */

.table-view .column-header-background{
    -fx-background-color: linear-gradient(#131313 0%, #424141 100%);
}

.table-view .column-header-background .label{
    -fx-background-color: transparent;
    -fx-text-fill: white;
}

.table-view .column-header {
    -fx-background-color: transparent;
}

.table-view .table-cell{
    -fx-text-fill: white;
}

.table-row-cell{
    -fx-background-color: -fx-table-cell-border-color, #616161;
    -fx-background-insets: 0, 0 0 1 0;
    -fx-padding: 0.0em; /* 0 */
}

.table-row-cell:odd{
    -fx-background-color: -fx-table-cell-border-color, #424242;
    -fx-background-insets: 0, 0 0 1 0;
    -fx-padding: 0.0em; /* 0 */  
}

.table-row-cell:selected {
    -fx-background-color: #005797;
    -fx-background-insets: 0;
    -fx-background-radius: 1;
}

.table-view > .virtual-flow > .scroll-bar:vertical,
.table-view > .virtual-flow > .scroll-bar:vertical > .track,
.table-view > .virtual-flow > .scroll-bar:vertical > .track-background, 
.table-view > .virtual-flow > .scroll-bar:horizontal,
.table-view > .virtual-flow > .scroll-bar:horizontal > .track,
.table-view > .virtual-flow > .scroll-bar:horizontal > .track-background {
    -fx-background-color: transparent;
}



.table-view > .virtual-flow > .scroll-bar > .increment-button, 
.table-view > .virtual-flow > .scroll-bar > .decrement-button {
    -fx-opacity: 0;
}*

你看,我已经改变了列标题的背景和其他一些东西。还有,我也改变了TableView的背景。所以我真的不知道我应该在我的CSS中改变什么。

- GhostfaceChilla -

6个回答

33

.table-view .filler 是您要查找的选择器。使用 scenic view 工具 能够很好地分析组件。


1

如果有人在寻找列显示隐藏按钮的CSS,这里是CSS。

.table-view .show-hide-columns-button {
    -fx-background-color: red;
    -fx-border-color: -fx-box-border;
    -fx-border-insets: -1 -1 0 0;
}

0
.table-view{
   -fx-background-color: transparent;
}

如果TableView中没有记录,背景颜色可以是白色。并且为占位符设置样式可能会更好。


0
我用以下 CSS 代码解决了这个问题:
.table-view .filler {
    -fx-border-insets: 10 //Enter value depending on thickness;
}

-2

试试这个

.table-view .filler{
    -fx-background-color: transparent;
}

-2

试试这个。

.table-view .column-header-background
{
    -fx-background-color: transparent;
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接