如何在表中选择包含 colspans 的列? [英] How do I select columns including colspans in a table?
本文介绍了如何在表中选择包含 colspans 的列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一个看起来像这样的表格:
Assume I have a table that looks like this:
<table>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="2"></td>
<td></td>
<td colspan="2"></td>
<td></td>
</tr>
<tr>
<td></td>
<td colspan="2"></td>
<td></td>
<td colspan="2"></td>
</tr>
</table>
如何选择第四列中的所有单元格,包括使用 CSS 跨越它的 td[colspan="2"]?
How do I select all the cells in the fourth column, including the td[colspan="2"] that spans to it with CSS?
推荐答案
虽然不漂亮但可以用多个选择器来完成:http://jsfiddle.net/r4atjtfx/1/
It's not pretty but can be done with multiple selectors: http://jsfiddle.net/r4atjtfx/1/
tr:first-child td:nth-child(4),
tr:first-child + tr td[colspan="2"] ~ td[colspan="2"],
tr:last-child td:nth-child(3) {
color: orange;
}
但是为了回答您的问题,不存在针对不同表格列的选择器.
But to answer your question no selector exists to target different table columns.
这篇关于如何在表中选择包含 colspans 的列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文