我正在尝试找出用来突出显示TableRow顶部的CSS。我使用它来重新排序行,这样任何重新排序的人都可以知道它将被插入到哪里。目前我只能在一行周围画一个矩形,但我只想要那个矩形的顶线。
.table-row-cell.drag {
-fx-focus-color: #00a9d3;
-fx-faint-focus-color: #00a9d322;
-fx-highlight-fill: -fx-accent;
-fx-background-color:
-fx-focus-color,
-fx-control-inner-background,
-fx-faint-focus-color,
linear-gradient(from 0px 0px to 0px 5px, derive(-fx-control-inner-background, -9%), -fx-control-inner-background);
-fx-background-insets: -0.2, 1, -1.4, 3;
-fx-background-radius: 3, 2, 4, 0;
}
发布于 2018-09-29 08:02:19
您可以为侧面指定不同的-fx-background-insets
。如果一种颜色应该只出现在一侧,则下一种颜色的插图将与标记颜色的插图匹配,但应着色的那一侧除外。
此外,我建议使用PseudoClass
而不是style类,因为这样就不需要确保不会多次添加一个类。
final PseudoClass mark = PseudoClass.getPseudoClass("mark");
...
boolean marked = ...
row.pseudoClassStateChanged(mark, marked);
下面的CSS稍微简化了一点,但它应该演示该方法:
.table-row-cell:mark {
-fx-background-color: -fx-table-cell-border-color, red, -fx-background;
/* show red highlight of size 2 at the top */
-fx-background-insets: 0, 0 0 1 0, 2 0 1 0;
}
https://stackoverflow.com/questions/52563426
复制相似问题