html - 如何处理表中除表头之外的所有行?
问题描述
我有一张这样的桌子:
<table class="revista">
<thead>
<tr>
<td><a href="http://example.com">MY LINK</a></td>
</tr>
</thead>
<tbody>
<tr>
<td>SUMMER 2020</td>
</tr>
</tbody>
</table>
我想独立地设置标题和第一行的样式,所以我有这个:
.revista thead {
font-size: 2.0em;
}
.revista tr:not(thead) td {
font-size: 1.2em;
}
对于我尝试过的第二个:
.revista tr:not(first-child) td {
font-size: 1.2em;
}
和
.revista tr:not(nth-child(1)) td {
font-size: 1.2em;
}
没有工作,我的意思是第二个也改变了第一个。
解决方案
您已经拥有thead
和tbody
作为单独的引用,因此不需要特殊表达式。我不确定您到底想要实现什么,但这应该为您提供您正在寻找的所有选项。
/* The header */
.revista thead {
font-size: 2.0em;
color: red;
}
/* The first row */
.revista tbody tr:first-child {
font-size: 2.0em;
color: green;
}
/* All (other) rows */
.revista tbody tr {
font-size: 1.2em;
color: blue;
}
<table class="revista">
<thead>
<tr>
<td>MY LINK</td>
</tr>
</thead>
<tbody>
<tr>
<td>SUMMER 2020</td>
</tr>
<tr>
<td>SUMMER 2021</td>
</tr>
<tr>
<td>SUMMER 2022</td>
</tr>
</tbody>
</table>
推荐阅读
- ms-project - 如何使用公式计算累计成本?
- excel - 如何将字段值转换为excel中的列?(无转置)
- flutter - 为什么flutter pub cache repair会下载以前使用的每个包版本?
- python-3.x - 在 Python 中删除一列的相似文本行
- python - PyCharm 文档字符串中未解决的属性引用问题
- python - 在 Pandas 中为每个唯一值创建一个数据框
- algorithm - 为什么我们每个深度只存储两三个杀手级动作?
- quarkus - 无论如何使用 quarkus-scheduler @Scheduled 和第二个下的速率?
- azure-devops - 从 Azure Devops 中的测试运行导出屏幕截图
- c++ - 我可以在双簧管中添加和/或替换音频源而不重新启动音频流吗?