CSS:固定标头表 - 滚动时,如何不专注于固定标头后面的视线外行?
背景
I有一个带固定标头的表(确切地说是固定< th>
),带有垂直滚动内容。您只需像往常一样在滚动条上上下滚动,就可以使用上下箭头键上下滚动。我强调了当前专注的行带有红色轮廓的地方。在下面亲自查看。
问题
问题是,当向下滚动并尝试使用up
箭头键时,它可以到达固定标头下方的第一行。顶行不可见,因此,当使用UP
键滚动时,请重点关注这一点。
问题
如何防止专注于“视图”行?理想情况下,我希望它是否达到最后一个可见的行,而不是固定标头后面的一排,它可以进一步向上滚动。也许我应该用标头做点什么?
最小可重复的代码
在这里是 jsfiddle代码
Background
I have a table with fixed header (fixed <th>
s to be exact), with vertically scrollable content. You just scroll up and down with the scroll bar as usual, and you can scroll up and down with up/down arrow keys. I am highlighting where is the currently focused row with a red outline. See for yourself below.
Problem
The problem is when scroll down a bit and try to go up with up
arrow key, it reaches the top row under the fixed header. the top row is not visible, so focusing on that when scrolling up with up
key is not favorable.
Question
How do I prevent focusing on a "out-of-view" row? Ideally I want it to scroll further up if it reaches the top last visible row, not the one behind the fixed header. Maybe I should do something with the header?
Minimum reproducible code
Here is the JSFiddle code
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将
container.scrolltop = 0
设置为编程滚动至非常顶。适应您案件的代码:You can just set
container.scrollTop = 0
to programmatically scroll to very top. Code adapted to your case: