我想更改Bootstrap表条纹的颜色。我已经阅读了以下问题:Bootstrap table striped: How do I change the stripe background colour?。因此,我可以用例如:
.table-striped > tbody > tr:nth-child(2n+1) > td,
.table-striped > tbody > tr:nth-child(2n+1) > th
{
background-color: red;
}
但是,我的应用程序需要为“选定的行”使用不同的颜色。因此,我有一个名为“ selectedRow”的CSS类,我们将其添加到选定的
tr
中。该属性是:.selectedRow td
{
background-color: blue;
color: black;
}
我需要对于所选行,背景色优先于剥离的Bootstrap表。那就是...对于
tr
,我添加css类selectedRow
我希望它们是蓝色,而不是红色。请注意,我不能在这里使用!important
(这是有原因的)。那么,还有另一种方法可以更改Bootstrap表条纹,以便我的selectedRow CSS类优先吗?
最佳答案
您必须比Bootstrap样式更具体。
例如这样:
.table-striped>tbody>tr.selectedRow:nth-child(odd)>td,
.table-striped>tbody>tr.selectedRow:nth-child(even)>td {
background-color: #819bbf;
color: black;
}
希望您能明白。