在twitter-bootstrap-3中你有什么办法可以使用内置的bootstrap配色方案吗?这段代码不起作用,我试过了#34; Active"和#34;成功"对于颜色而不是public enum RelationShip {
FRIEND, ENEMIE, FAMILY
}
public class Contact {
private RelationShip relationshipType;
public void setRelationShipType(RelationShip relationShip) {
...
}
public boolean areWeFriends() {
if (relationshipType==Relationship.FRIEND)
return true;
else
return false;
}
}
,但它们没有用。
background-color
答案 0 :(得分:6)
Bootstrap有一些内置的Contextual backgrounds,可以添加到任何元素
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.6/united/bootstrap.min.css">
<table class="table bg-primary"><tr><td>Hello</td></tr></table>
<table class="table bg-success"><tr><td>Hello</td></tr></table>
<table class="table bg-info"><tr><td>Hello</td></tr></table>
<table class="table bg-warning"><tr><td>Hello</td></tr></table>
<table class="table bg-danger"><tr><td>Hello</td></tr></table>
&#13;
此外,您的代码示例无法正常工作,因为您在class
属性与style
属性中添加了css ..应该是这样的< / p>
<table class="table table-bordered" style="background-color: white">
答案 1 :(得分:6)
你可以使用.table-striped
类来制作斑马纹。
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<table class="table table-striped">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
<td>john@example.com</td>
</tr>
<tr>
<td>Mary</td>
<td>Moe</td>
<td>mary@example.com</td>
</tr>
<tr>
<td>July</td>
<td>Dooley</td>
<td>july@example.com</td>
</tr>
</tbody>
</table>
或强>
如果您想要超过2种颜色,可以使用Contextual classes,您可以将其应用于tr
或td
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<table class="table">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td class="active">John</td>
<td class="success">Doe</td>
<td class="danger">john@example.com</td>
</tr>
<tr class="warning">
<td>Mary</td>
<td>Moe</td>
<td>mary@example.com</td>
</tr>
<tr class="info">
<td>July</td>
<td>Dooley</td>
<td>july@example.com</td>
</tr>
</tbody>
</table>