列组合器
列组合器 (||) 放置在两个 CSS 选择器之间。它只匹配由第二个选择器匹配的元素,这些元素属于由第一个选择器匹配的列元素。
css
/* Table cells that belong to the "selected" column */
col.selected||td {
background: gray;
}
语法
css
/* The white space around the || combinator is optional but recommended. */
column-selector || cell-selector {
/* style properties */
}
示例
HTML
html
<table border="1">
<colgroup>
<col span="2" />
<col class="selected" />
</colgroup>
<tbody>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td colspan="2">D</td>
<td>E</td>
</tr>
<tr>
<td>F</td>
<td colspan="2">G</td>
</tr>
</tbody>
</table>
CSS
css
col.selected||td {
background: gray;
color: white;
font-weight: bold;
}
结果
规范
| 规范 |
|---|
| 选择器 Level 4 # 选择器定义-列 |
浏览器兼容性
目前没有浏览器支持此功能。