【发布时间】:2017-11-19 18:16:16
【问题描述】:
我第一次使用 COLGROUP 和 COL 元素来突出显示数据表的特定列。我的表格还有一些特殊的行,例如页眉、页脚,也许还有突出显示的行。我发现将样式分配给行和列样式的交集并不简单。有没有可能写出这样的CSS选择器?
简单示例:
<table>
<colgroup>
<col span="2">
<col class="col_highlight">
</colgroup>
<thead>
<tr>
<th>Product</th> <th>Sales</th> <th>Profit</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tools</td> <td>$12,345.67</td> <td>$345.67</td>
</tr>
<tr>
<td>Books</td> <td>$8,910.11</td> <td>$910.11</td>
</tr>
</tbody>
</table>
第三列以样式col_highlight 突出显示(只是背景颜色不同)。我希望这种特殊颜色显示在表格主体(<TD> 元素)中,而不是标题(<TH> 元素)中。这些单元格的 CSS 选择器是什么?我试过了……
td .col_highlighttd.col_highlight.col_highlight td
【问题讨论】:
-
没有。如果它的 about thead tr 没有显示突出显示的 col bg,则为其 tr 设置一个 bg-color,并且 col bg-color 将被隐藏:codepen.io/anon/pen/eRgZya
-
不确定我完全了解您的目标。你能画一个简单的图形例子来展示你想要达到的效果吗?
标签: html css html-table css-selectors