【发布时间】:2018-07-17 09:38:55
【问题描述】:
我有一个可能超过 100 行的表 所以我使用了 Scroll 类来固定高度.. 我在表格中有一个单选按钮
问题是在渲染表格时假设默认选择第 50 行,默认情况下它必须到该位置 每行都有一个由行代码给出的相应类.. 我只想将它滚动到特定的类。 滚动是针对特定的 div。我需要转到表内的特定类
HTML
<table class="table-scroll">
<tr class="radio1"><td>1</td></tr>
<tr class="radio2"><td>2</td></tr>
<tr class="radio3"><td>3</td></tr>
</table>
CSS
.table-scroll{
max-height:500px;
overflow-x:hidden;
overflow-y:scroll;
margin-bottom:20px;
border-top:1px solid #ccc;
border-bottom:1px solid #ccc;
}
JS
<script>
How to scroll to particular class suppose radio3??
</script>
【问题讨论】:
-
您可以使用哈希位置并导航到它吗?即 page.html#row50
-
我该怎么做?
-
使用javascript,window.location.href?
-
我在特定 div 内有一个滚动条,而不是窗口滚动条
-
如果你知道div内每一行的高度和表格上方的内容,那么在JS中很容易。
标签: javascript jquery html css bootstrap-4