Html Bootstrap:tr 类“警告”在条带表中不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18864070/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 13:31:57  来源:igfitidea点击:

Bootstrap: tr class "warning" doesn't work in striped-table

htmlcsstwitter-bootstrap

提问by Jonathan

I've got a table defined <table class="table table-striped">with some rows like <tr class="success">, <tr class="info">, and <tr class="warning">.

我有定义的表<table class="table table-striped">与像一些行<tr class="success"><tr class="info"><tr class="warning">

The successand infotable-rows show up fine: red and blue just as they should be. But the warningrows don't show yellow as expected. They're just regular, zebra-stripe white or gray.

successinfo表行显示了罚款:红色和蓝色就像他们应该的。但warning行没有按预期显示黄色。它们只是普通的斑马条纹白色或灰色。

Weird thing is, if I add table-hoverto the table's classes, the warningrows will show yellow, but only when hovered. The successand inforows, however, always show their colors, hover or no.

奇怪的是,如果我添加table-hover到表的类中,warning行将显示为黄色,但仅在悬停时显示。该successinfo行,然而,总是打回原形,悬停或没有。

回答by Robbie Averill

Regarding this issue with v3.0.3 (which will be fixed in v3.1, whenever they release it), a quick/rough fix for this is to add !importantoverrides to some specific CSS for this issue:

关于 v3.0.3 的这个问题(将在 v3.1 中修复,无论何时发布),!important对此问题的快速/粗略修复是为此问题添加对某些特定 CSS 的覆盖:

.table-striped > tbody > tr > .danger,
.table-striped > tbody > .danger > td,
.table-striped > tbody > .danger > th {
  background-color: #f2dede !important;
}

Obviously add this for thead, tfootetc and success, infoetc if you use those. I'm only using danger, and only in the tbody. I put these modifications in my bootstrap.css file, so that when I upgrade to v3.1 it will update anyway.

显然,这增加了theadtfoot等和successinfo如果你使用这些等。我只使用danger,并且只在tbody. 我将这些修改放在 bootstrap.css 文件中,这样当我升级到 v3.1 时,它无论如何都会更新。

回答by Richard

Looks like this is a know bug in v3.0.3 and will be fixed in v3.1.0

看起来这是 v3.0.3 中的一个已知错误,将在 v3.1.0 中修复

https://github.com/twbs/bootstrap/issues/11728

https://github.com/twbs/bootstrap/issues/11728

For now I'm just going to remove class: table-striped to make the colours appear again.

现在我只是要删除 class: table-striped 以使颜色再次出现。

回答by Dave Strickler

Related bug... In Bootstrap 2.1.0, the "tr.warning" was left out, so that bootstrap.css was

相关错误...在 Bootstrap 2.1.0 中,“tr.warning”被排除在外,因此 bootstrap.css 是

.table tbody tr.success td {
  background-color: #dff0d8;
}
.table tbody tr.error td {
  background-color: #f2dede;
}
.table tbody tr.info td {
  background-color: #d9edf7;
}

But it should look something like:

但它应该看起来像:

.table tbody tr.success td {
  background-color: #dff0d8;
}
.table tbody tr.error td {
  background-color: #f2dede;
}
.table tbody tr.info td {
  background-color: #d9edf7;
}
.table tbody tr.warning td {
  background-color: lightgoldenrodyellow;
}

Note the color choice for "tr.warning" is my choice, and not a Bootstrap default color.

请注意,“tr.warning”的颜色选择是我的选择,而不是 Bootstrap 的默认颜色。

回答by olahell

If you are using LESS and build your own bootstrap I suggest adding !importantto the bg-variant-mixin:

如果您使用 LESS 并构建自己的引导程序,我建议添加!importantbg-variant-mixin:

// Fix for known bug bg-variant, fixes issues with striped tables
.bg-variant(@color) {
    background-color: @color !important;
    a&:hover,
    a&:focus {
        background-color: darken(@color, 10%) !important;
    }
}