答案 0 :(得分:2)
以下适用于我:
.table-view:focused .table-row-cell:focused {
-fx-background-color: -fx-table-cell-border-color, -fx-background;
-fx-background-insets: 0, 0 0 1 0;
}
说明:
default stylesheet针对有针对性的非选定行具有以下CSS规则:
/* focused cell (keyboard navigation) */
.table-view:focused:row-selection > .virtual-flow > .clipped-container > .sheet > .table-row-cell:focused {
-fx-background-color: -fx-background, -fx-cell-focus-inner-border, -fx-background;
-fx-background-insets: 0, 1, 2;
}
这是通过绘制三个不同插图的三个背景(一种称为&#34的技术;嵌套背景")来实现的。第一个插入为0(填充整行),并且为默认背景颜色(-fx-background
)。第二个插图为1(因此前一个背景的一个像素可见);它用查找的颜色-fx-cell-focus-inner-border
填充一个矩形。第三个具有2的插图(因此它使中间背景的一个像素可见)并且再次具有默认颜色。
默认行背景由
定义.table-row-cell {
-fx-background: -fx-control-inner-background;
-fx-background-color: -fx-table-cell-border-color, -fx-background;
-fx-background-insets: 0, 0 0 1 0;
-fx-padding: 0;
-fx-text-fill: -fx-text-background-color;
}
这再次使用"嵌套背景",第一个具有零插图和背景颜色-fx-table-cell-border-color
,第二个具有默认背景和仅沿底边的一个像素的插图。所以这里的效果是1像素宽的底部边框。
我上面使用的CSS只是将焦点行重新定义为非焦点行。