gpt4 book ai didi

html - 有条件地覆盖表上的 CSS 类

转载 作者:行者123 更新时间:2023-11-28 17:04:42 24 4
gpt4 key购买 nike

我有一张装饰有以下类的 table :

<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);
}

enter image description here

最佳答案

以这种方式自定义您的 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;
}

关于html - 有条件地覆盖表上的 CSS 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50391592/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com