我想使用 CSS 将文本放在一列斜体中。目前,我的表格结构如下,但我无法将右列的文本设置为斜体。
CSS(在头部部分(:
<style>
.col-right-col{
font-style: italic;
}
</style>
.HTML:
<table>
<colgroup>
<col class="col-left-col">
<col class="col-right-col">
</colgroup>
<tbody>
<tr>
<th scope="col">Left Col Header</th>
<th scope="col">Right Col Header</th>
</tr>
<tr>
<td>Row 1 Left</td>
<td>Row 1 Right</td>
</tr>
<tr>
<td>Row 2 Left</td>
<td>Row 2 Right</td>
</tr>
<tr>
<td>Row 3 Left</td>
<td>Row 3 Right</td>
</tr>
</tbody>
</table>
您可以做的是使用td:nth-child()
将行 1/2/3 设为右斜体:
td:nth-child(2) {
font-style: italic;
}