我正在使用 bootstrap 来为我的表格行提供悬停效果。但是我想在选择表格行时删除悬停效果。 I set a class (select-row) using JavaScript when a row is selected.似乎不适合我。我在 css 中使用 not 子句。
我的CSS:
.table-hover > tbody > tr:not(.select-row):hover > td,
.table-hover > tbody > tr:not(.select-row):hover > th {
background-color: #f5fafe;
color: black;
}
tr.select-row {
background-color: #bddef9;
}
网址:
<table class="table table-condensed table-hover">
<tr>
<td>xxx</td>
<td>xxx</td>
</tr>
</table>
原文由 MindGame 发布,翻译遵循 CC BY-SA 4.0 许可协议
为了让选中的行背景不发生变化,你需要专门覆盖现有的悬停样式。
Bootstrap 的目标是悬停时的
td
背景,而不是tr
。这有效:
演示小提琴