twitter-bootstrap Twitter Bootstrap 在使用 <th> 而不是 <td> 时不会改变颜色表标题行的颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14476275/
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
Twitter Bootstrap is not changing color table header row's color while using <th> instead of <td>
提问by Siddharth
In my rails 3.2 application I have to display a table. So I used the twitter bootstrap's class "table table-bordered"to format it. And then to change it's rows color I also used class "info" and "success" described here.
在我的 rails 3.2 应用程序中,我必须显示一个表格。所以我使用了 twitter bootstrap 的类“table table-bordered”来格式化它。然后要更改它的行颜色,我还使用了此处描述的“信息”和“成功”类。
The table code in my page is as follows:-
我页面中的表格代码如下:-
<table class="table table-bordered">
<tr class="info">
<th>Your Links</th>
<th></th>
<th></th>
<th></th>
</tr>
<% @links.each do |link| %>
<tr class="success">
<td><%= link_to linkbunch_url(link.link), linkbunch_url(link.link) %></td>
<td><%= link_to 'Show', linkbunch_url(link.link) %></td>
<td><%= link_to 'Edit', edit_url(link.link) %></td>
<td><%= link_to 'Destroy', destroy_url(link.link), method: :delete, data: { confirm: 'Are you sure ?' } %></td>
</tr>
<% end %>
</table>
Guess what it's changing all rows colors except the first row that is the the head row of table. But when changed the ""to ""then it's working fine. But because it's just a simple row not a table header row so it's fonts are not bold type.
猜猜它正在改变除表头行的第一行之外的所有行颜色。但是,当改变了“”到“”那么它的正常工作。但是因为它只是一个简单的行而不是表格标题行,所以它的字体不是粗体。
So How to change the header row's color without using the instead of ??
那么如何在不使用的情况下更改标题行的颜色 代替 ??
Thanks...
谢谢...
采纳答案by hajpoj
回答by gavit
<table class="table table-bordered">
<thead>
<tr class="info">
<th>Your Links</th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<% @links.each do |link| %>
<tr class="success">
<td><%= link_to linkbunch_url(link.link), linkbunch_url(link.link) %></td>
<td><%= link_to 'Show', linkbunch_url(link.link) %></td>
<td><%= link_to 'Edit', edit_url(link.link) %></td>
<td><%= link_to 'Destroy', destroy_url(link.link), method: :delete, data: { confirm: 'Are you sure ?' } %></td>
</tr>
<% end %>
</tbody>
</table>

