列組合器
列組合器 (||) 放置在兩個 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 # 選擇器定義-列 |
瀏覽器相容性
目前沒有瀏覽器支援此功能。