gpt4 book ai didi

html - 表格html底部从右到左的滚动条

转载 作者:太空宇宙 更新时间:2023-11-04 06:12:27 25 4
gpt4 key购买 nike

在下面的 fiddle 中,我创建了一个表格,我需要它从右到左。一切都很好,只是表格底部的滚动条最初位于页面左侧,因此用户看不到第一列。

FiddleDemo

如何设置滚动条的初始位置在右边,我可以看到第一列。

以下是fiddle链接中的代码。

HTML

<table>
<tr>
<th>RTL Header 1</th>
<th>RTL Header 2</th>
<th>RTL Header 3</th>
<th>RTL Header 4</th>
<th>RTL Header 5</th>
<th>RTL Header 6</th>
<th>RTL Header 7</th>
<th>RTL Header 8</th>
<th>RTL Header 9</th>
<th>RTL Header 10</th>
<th>RTL Header 11</th>
<th>RTL Header 12</th>
<th>RTL Header 13</th>
<th>RTL Header 14</th>
</tr>
<tr>
<td>RTL Content 1</td>
<td>RTL Content 2</td>
<td>RTL Content 3</td>
<td>RTL Content 4</td>
<td>RTL Content 5</td>
<td>RTL Content 6</td>
<td>RTL Content 7</td>
<td>RTL Content 8</td>
<td>RTL Content 9</td>
<td>RTL Content 10</td>
<td>RTL Content 11</td>
<td>RTL Content 12</td>
<td>RTL Content 13</td>
<td>RTL Content 14</td>
</tr>
</table>

CSS

table {
direction: rtl;
font-family: Vazir;
border-collapse: collapse;
width: 100%;
}

th {
direction: rtl;
width: 100%;
border: 1px solid #848080;
text-align: center;
padding: 8px;
white-space: nowrap;
}
td{
direction: rtl;
width: 100%;
border: 1px solid #848080;
text-align: center;
padding: 8px;
white-space: nowrap;
}
td:last-child{
width:100%;
}
th:last-child{
width:100%;
}
tr:nth-child(even) {
background-color: #dddddd;
}

最佳答案

在表格的最后一个单元格上使用 scrollIntoView 方法作为

document.getElementById("last").scrollIntoView();

last 是最后一个表格单元格的 id

<th id="last">RTL Header 1</th>

关于html - 表格html底部从右到左的滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56312737/

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