如何只选择td
的{{1}}的第一个colgroup
?如果我有{5}列table
且使用5 table
?
答案 0 :(得分:17)
table colgroup:first-child td:first-child
来自w3schools:
注意:要让
:first-child
在IE中工作,必须声明<!DOCTYPE>
。
<强>更新强>
正如DisgruntledGoat正确提到的那样,td
元素不是colgroup
元素的后代。但第一个colgroup
显然总是包含第一列,所以
table tr td:first-child
选择每行中的第一个td
,应该这样做。