twitter-bootstrap Bootstrap 危险类不适用于表格行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23922055/
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
Bootstrap danger class not working for a table row
提问by Hommer Smith
I have the following table in my Rails app:
我的 Rails 应用中有下表:
<table class='table table-bordered table-hover table-striped'>
<thead>
<tr>
<th>ID</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr class='danger'>
<td><%= order.id %></td>
<td><%= order.status.name %></td>
</tr>
</tbody>
</table>
And the row with class 'danger' doesn't change the color. However, if I use the class 'success' it changes correctly.
具有“危险”类的行不会改变颜色。但是,如果我使用“成功”类,它会正确更改。
I am using the twitter-bootstrap-rails gem.
我正在使用 twitter-bootstrap-rails gem。
采纳答案by Kirti Thorat
twitter-bootstrapgem is currently using bootstrap v 2.3.2.
twitter-bootstrapgem 目前正在使用bootstrap v 2.3.2.
And as per the Bootstrap version 2.3.2 Documentation For Tablesfollowing are the available row classes:
根据Bootstrap 版本 2.3.2 Documentation For Tables以下是可用的行类:
Optional row classes
Use contextual classes to color table rows.
.success Indicates a successful or positive action.
.error Indicates a dangerous or potentially negative action.
.warning Indicates a warning that might need attention.
.info Used as an alternative to the default styles.
Which is why .successworked but NOT .danger.
这就是为什么.success工作但没有.danger。
I suppose you are looking for .errorclass.
我想你正在寻找.error课程。
回答by faby
it seems to be a know bug with tables.
这似乎是表格的一个已知错误。
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 中修复
refer this bug error pageand this stack question
回答by dev_dodiya
go through the https://getbootstrap.com/docs/4.3/content/tables/#contextual-classeshere they specified all row and cell classes, you should modify your
通过https://getbootstrap.com/docs/4.3/content/tables/#contextual-classes在这里他们指定了所有行和单元格类,你应该修改你的
<table class='table table-bordered table-hover table-striped'>
<thead>
<tr>
<th>ID</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr class='table-danger'>//Modified line
<td><%= order.id %></td>
<td><%= order.status.name %></td>
</tr>
</tbody>
回答by martinezjc
Maybe you're using an old version for the Bootstrap gem, by the way the default gem has not been updated to the version 3 of Bootstrap, try using this resource
也许您使用的是旧版本的 Bootstrap gem,顺便说一下默认 gem 尚未更新到 Bootstrap 的第 3 版,请尝试使用此资源
https://github.com/jasontorres/bootstrap-on-rails
https://github.com/jasontorres/bootstrap-on-rails
As @Kirti said the correct class for the Bootstrap 2 version must be .errorinstead of .dangerwatch the official documentation:
正如@Kirti 所说,Bootstrap 2 版本的正确类必须是.error而不是.danger观看官方文档:

