【发布时间】:2013-10-24 18:51:21
【问题描述】:
这听起来很简单,但我找不到很多关于它的帖子。
基本上我想要第一列红色,第二个绿色,第三个红色等等......
如何在 css 中做到这一点?
这是我的 html 代码(我使用的是 bootstrap 3):
<table class="table table-striped">
<thead>
<tr>
<th>Welsh</th>
<th>English</th>
</tr>
</thead>
<tbody>
<tr>
<td>Shwmae <a href="#" onclick="playAudio('shwmae');"><span class="glyphicon glyphicon-volume-up play"></span></a></td>
<td>Hello</td>
</tr>
<tr>
<td>Bore da <a href="#" onclick="playAudio('boreda');"><span class="glyphicon glyphicon-volume-up play"></span></a></td>
<td>Good morning</td>
</tr>
<tr>
</tbody>
</table>
我曾尝试使用以下 CSS,但它没有做任何事情:
col:first-child {background: #FF0}
col:nth-child(2n+3) {background: #CCC}
【问题讨论】:
-
请注意,目前,所有答案都不适用于旧版浏览器
标签: html css twitter-bootstrap