twitter-bootstrap 更改引导表的边框颜色的最佳方法是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30573978/
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
What is the best way to change the border-color of a bootstrap table?
提问by cyber8200
I use bootstrap table class. The default border color is grey/silver - I think.
我使用引导表类。默认边框颜色是灰色/银色 - 我认为。
But I want to change the border-color to red, but I couldn't get it to work.
但是我想将 border-color 更改为red,但我无法让它工作。
This is what I have

这就是我所拥有的

CSS
CSS
.table {
border: red solid 1px !important;
}
HTML : Table
HTML : 表格
<table class="table table-bordered piechart-key ">
<thead >
<th></th>
<th></th>
<th> Item Summary</th>
<th> Item List</th>
</thead>
<tbody>
<tr>
<td width="30"></td>
<td width="200">
> 50% of students answered these items correctly
</td>
<td width="50">5/25</td>
<td width="100">5,10,15,19,23</td>
</tr>
<tr>
<td width="30"></td>
<td width="200">50% up to 75% of students answered these items correctly</td>
<td width="50">8/25</td>
<td width="100">3,7,11,13,14,16,21,22</td>
</tr>
<tr>
<td width="30"></td>
<td width="200">≥ 75% of students answered these items correctly</td>
<td width="50">12/25</td>
<td width="100">1,2,4,6,8,9,12,17,18,20,24,25</td>
</tr>
</tbody>
</table>
What is the best way to change the border-color of a bootstrap table ?
更改引导表的边框颜色的最佳方法是什么?
回答by Mauricio Moraes
Try to apply it to the cells:
尝试将其应用于单元格:
.table td{
border: red solid 1px !important;
}
For the header:
对于标题:
.table th{
border: red solid 1px !important;
}
http://jsfiddle.net/w0b73dwt/7/
http://jsfiddle.net/w0b73dwt/7/
EDIT
编辑
OBS: I used the !importantdirective 'cause I didn't find other simple way to do it. Of course, we all know it is a bad css practice, but in some cases we'll have to run the risk. Other waywould be to find exactly how bootstrap declares its style and create a css selector with higher priority for tdand th. In this case this could break at the first bootstrap update.
OBS:我使用了!important指令,因为我没有找到其他简单的方法来做到这一点。当然,我们都知道这是一种糟糕的 css 实践,但在某些情况下,我们将不得不承担风险。 另一种方法是确切地找到引导程序如何声明其样式并为td和th创建一个具有更高优先级的css选择器。在这种情况下,这可能会在第一次引导更新时中断。

