【问题标题】:Change the color of single rows of a Bootstrap striped table更改 Bootstrap 条带表单行的颜色
【发布时间】:2016-04-11 23:18:28
【问题描述】:

我不想使用 JQuery 更改条带表的各个行的颜色:

$("#rowElementId").addClass("activeRow");

css 类 activeRow 如下所示:

.activeRow {
background-color: #d9d9d9;
}

表格本身如下所示:

<table class="table table-striped">
    <thead>
        <tr id=...>
        ...

问题是,我的解决方案 JQuery 指令仅适用于条纹表的白色行。我怎样才能改变这个?

在这里你可以找到我的问题的一个例子:Bootstrap

【问题讨论】:

标签: jquery css twitter-bootstrap


【解决方案1】:

特异性已关闭。当前行颜色选择器在引导程序 3 中如下所示:.table-striped&gt;tbody&gt;tr:nth-of-type(odd)

你应该把你的风格变成这样以增加它的特异性:

.table-striped>tbody>tr.activeRow{
    background-color: #d9d9d9;
}

编辑:here is a fork of your bootply 演示此方法。 (为了清楚起见,我添加了额外的行)

【讨论】:

    【解决方案2】:

    尝试将!important 添加到您的规则中,例如

    .activeRow {
      background-color: #d9d9d9 !important;
    }
    

    【讨论】:

    • 这个“有效”,但通常我不建议你搞乱!important 规则,除非你知道它不会造成任何问题。
    猜你喜欢
    • 1970-01-01
    • 2014-01-16
    • 2020-11-25
    • 1970-01-01
    • 1970-01-01
    • 2018-08-14
    • 1970-01-01
    • 2018-01-26
    • 2013-08-15
    相关资源
    最近更新 更多