选择个假设我们有这个网站:分配给特定的列
<table>
<caption>test</caption>
<colgroup>
<col class='col1'/>
<col class='col2'/>
<col class='col3'/>
</colgroup>
<thead>
<tr>
<th>Column1</th>
<th>Column2</th>
<th>Column3</th>
</tr>
</thead>
<tbody>
<tr>
<td>Cell1.1</td>
<td>Coll1.2</td>
<td>Coll1.3</td>
</tr>
<tr>
<td>Cell2.1</td>
<td>Coll2.2</td>
<td>Coll2.3</td>
</tr>
<tr>
<td>Cell3.1</td>
<td>Coll3.2</td>
<td>Coll3.3</td>
</tr>
</tbody>
</table>
而且我们有这个CSS:
.col2{
background-color: #AAA;
}
.col1,col3{
background-color: #FFF;
}
现在我想选择与col2
列相关联的th
在其上放置背景图像。
喜欢的东西.col2:th
或th.col2
或.col2 th
...
我想选择th
而是由col
元素寻址; 我正在设置类col
,它是动态的,所以我想访问th
col
元素而不是直接
如何选择与特定col
标签与CSS关联的特定标签?
(小记:这不会对IE8的工作,因为它是CSS3)下 – Pieter
@Pieter是的,你可以使用CSS3与[Selectivizr]馅饼(http://selectivizr.com/) –
是和否;我想通过从'col'元素寻址来选择第二个'th';我在'col'设置类,它是动态的,所以我想通过'col'元素访问'th'而不是直接访问 – RYN