gpt4 book ai didi

html - 如何使用 CSS 右对齐表格的最后两列

转载 作者:太空狗 更新时间:2023-10-29 13:40:19 28 4
gpt4 key购买 nike

我想右对齐表格最后两列的文本。

<table>
<tr>
<th>H 1</th>
<th>H 2</th>
<th>H 3</th>
<th>H 4</th>
</tr>
<tr>
<td rowspan='3'>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
</table>

每行中的列数不同,我不确定如何使用 css:nth-child 选择每行中的最后两个 td 项。

最佳答案

http://jsfiddle.net/BB9ty/

th:last-child,
td:last-child,
th:nth-last-child(2),
td:nth-last-child(2) {
text-align: right;
}

关于html - 如何使用 CSS 右对齐表格的最后两列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20183392/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com