我有一张用以下类装饰的桌子:
<table class="table table-striped table-borderless nowrap">
对于某些用户,我想像这样更改行的背景颜色:
<tr class="@(item.Assigneee == UserSession.User.Id ? "alert alert-primary" : " ")">
但我无法让它覆盖表类。我尝试添加 !important,但它仍然显示来自表类的背景颜色。
我看到添加了类:
<tr class="alert alert-primary odd" role="row">
但是背景颜色被穿透了,它仍然被显示:
.table-striped tbody tr:nth-of-type(odd) {
background-color: rgba(0, 0, 0, 0.05);
}
以这种方式自定义您的 CSS。
对于 Bootstrap 4
.table-striped tbody tr:not(.alert-primary):nth-of-type(odd) {
background-color: rgba(0, 0, 0, 0.05);
}
对于 Bootstrap 3.7
.table-striped>tbody>tr:not(.alert-primary):nth-of-type(odd) {
background-color: #f9f9f9;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句