我有以下带CSS的html。 http://jsfiddle.net/3zcwwjj5/4/
表是动态的,因此列数可能不同。 如何(使用CSS)我可以使用类 comment 选择最后一个表格单元格。 我的CSS无效。
<table>
<tr>
<td class="comment">1</td>
<td class="something">2</td>
<td class="comment">3</td>
<td class="comment">4</td>
<td class="something">5</td>
</tr>
<tr>
<td class="comment">1</td>
<td class="something">2</td>
<td class="comment">3</td>
<td class="comment">4</td>
<td class="something">5</td>
</tr>
</table>
.comment:first-of-type {
background: red;
}
.comment:last-of-type {
background: blue;
}
.something:first-of-type{
background: yellow;
}
.something:last-of-type{
background: magenta;
}