CSS - 仅在表格的主体内选择标签

标签 css css-selectors

我想使用 css 选择器只获取带有 tbody 的第 th 个标签。 thead 部分中还有 th 标签,我不希望选择器包含这些标签。这是我正在使用的标记。是否有选择器来完成此操作?

<table class="bgtable">
<thead><tr><td width="40%">&nbsp;</td>
<th class="tdplain">Grade 4</th>
<th class="tdplain">Grade 8</th>
<th class="tdplain">Grade 12</th>
</tr>
</thead>
<tbody><tr><th class="tdplain">Civics (2010)</th>
<td class="tdplain">769K</td>
<td class="tdplain">577K</td>
<td class="tdplain">1179K</td>
</tr>
</tbody>
</table>

最佳答案

.bgtable tbody th {
   color: red;
}

关于CSS - 仅在表格的主体内选择标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2454936/

相关文章:

javascript - 使用 AngularJS 在悬停时上下滑动框

html - CSS、HTML : What's the best way to add space to the inside of a scrollable element?

css - LessCSS 停止处理样式

css - Material Design Lite 徽章变色

javascript - 如何使用 JS 选择 input::placeholder?

css - 在 Angular Material 的 md-option 上将空白设置为正常

javascript - Twitter Bootstrap 如何将下拉选择替换为菜单按钮

css - SASS:从列表中随机选择背景图像

css - 从最后一个/底部选择第 n 个 child

javascript - 如何选择包含引号的元素?