這聽起來很簡單,但我無法找到關於它的許多帖子。如何替換表格中的列背景顏色?
基本上我想的第一列紅,綠2號,3號紅等..
我怎麼能做到這一點在CSS?
這裏是我的html代碼(我用的自舉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}
http://jsfiddle.net/TG8cd/? – underscore
Duplicate of:http://stackoverflow.com/questions/19430005/add-alternate-background-style-to-odd-rows-of-html-table/19430053#19430053 –
請注意,目前,沒有答案將在舊版瀏覽器中工作 – ediblecode