我正在尝试为选定的表格行添加红色边框,并且该行中的元素正在移动。

这是我的CSS:

.my-table .table-row-cell:filled:selected {
    -fx-border-color: red;
}

这是其外观的屏幕截图。

java - Javafx表行边框导致其中的元素移位-LMLPHP

我该如何纠正?
我尝试过更改边框插图,但似乎没有效果。
-fx-background-insets: 0, 1 ;

用于创建表的代码是:
<TableView styleClass="my-table" editable="false" >
    <columns>
        <TableColumn fx:id="columnNumber" minWidth="70" prefWidth="70" sortable="false" text="Solution" />
        <TableColumn fx:id="columnOne" minWidth="0" prefWidth="40" sortable="false" text="columnOne" />
        <TableColumn fx:id="columnTwo" minWidth="40" prefWidth="40" sortable="false" text="columnTwo" />
        <TableColumn fx:id="columnThree" minWidth="70" prefWidth="70" sortable="false" text="columnThree" />
        <TableColumn fx:id="columnFour" minWidth="40" prefWidth="40" sortable="false" text="columnFour" />
        <TableColumn fx:id="columnFive" minWidth="80" prefWidth="80" sortable="false" text="columnFive" />
        <TableColumn fx:id="columnSix" minWidth="80" prefWidth="80" sortable="false" text="columnSix" />
        <TableColumn fx:id="columnSeven" minWidth="80" prefWidth="80" sortable="false" text="columnSeven" />
        <TableColumn fx:id="columnEight" minWidth="180" prefWidth="180" sortable="false" text="columnEight" />
        <TableColumn fx:id="action" minWidth="100" prefWidth="100" sortable="false" text="" />
    </columns>
</TableView>

应用的样式为:
.table-view {
    -fx-table-cell-border-color: transparent;
}

最佳答案

她是一个肮脏的解决方法:

 .my-table .table-row-cell:filled:selected {
    -fx-border-color: red;
    -fx-border-insets: 0 -1 0 -1;
}

要么
.my-table .table-row-cell:filled:selected {
    -fx-border-color: red;
    -fx-padding: -1;
}

07-26 09:28
查看更多