【发布时间】:2021-09-16 13:18:40
【问题描述】:
这有点类似于Tabulator row formatting removes hover effect, while cell formatting doesn't - 但不完全一样。
需要动态更改表格颜色(用户特定)。因此,我覆盖了工作正常的 Tabulator css 类。但是,当我使用 cellFormater 更改单元格的背景色时,悬停背景色和所选背景色都不起作用。
为了更清楚(希望如此):我想为冻结列和具有特定值的单元格设置背景色。我想保留选定的背景颜色和悬停背景颜色。
由于我是 CSS 新手,如果有人能帮我解决这个问题,我将不胜感激。
我修改了另一个线程中的Codesandbox 以进行演示。 绿色和黄色单元格用 cellFormatter 着色。 第 3 行和第 4 行被选中,应该是粉红色的。 对于完整的行,悬停背景色应为黑色。 如您所见,文本颜色也会出现问题。 Screenshot
尝试使用这些类失败(!important 是一次绝望的尝试):
.tabulator-row.tabulator-selected {
background-color: rgb(250, 34, 203) !important;
}
.tabulator-row:hover {
background-color: rgb(0, 0, 0) !important;
color: rgb(0, 119, 255) !important;
font-weight: 900;
}
.tabulator-frozen:hover {
background-color: rgb(238, 5, 5) !important;
color: rgb(154, 195, 243) !important;
}
旁注:
- 设置
.tabulator-row .tabulator-cell:hover适用于单个单元格 - 设置
.tabulator-row .tabulator-frozen:hover仅在光标位于冻结单元格上时有效
【问题讨论】:
-
刚刚注意到,如果我通过
rowFormatter: row => { row.getCells()[3].getElement().style.backgroundColor = "red"}设置单元格背景色,行为是相同的
标签: javascript css tabulator