我正在使用Bootstrap 3,并且我有一个显示一些数据的表格。在这个表格中,我应用了一些JavaScript来进行条件格式化,如果满足某个条件,我会将元素的类设置为"red"。
.red {
background-color:red;
color:white;
}
HTML的元素如下:
<td class="red">0</td>
我现在遇到一个问题,奇数行的文本颜色可以应用,但是背景颜色被 Bootstrap 的下一个 CSS 覆盖了。
.table-striped > tbody > tr:nth-child(odd) > td,
.table-striped > tbody > tr:nth-child(odd) > th {
background-color: #f9f9f9;
}
我该如何解决这个冲突并确保红色类具有优先权?
!important
,无论您在做什么! - Sean Ryan