查看大表格时,HTML 表格标题始终显示在窗口顶部 [英] HTML table headers always visible at top of window when viewing a large table

查看:20
本文介绍了查看大表格时,HTML 表格标题始终显示在窗口顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够调整"HTML 表格的演示文稿以添加单个功能:向下滚动页面以使表格在屏幕上但标题行不在屏幕上时,我希望标题在查看区域的顶部保持可见.

I would like to be able to "tweak" an HTML table's presentation to add a single feature: when scrolling down through the page so that the table is on the screen but the header rows are off-screen, I would like the headers to remain visible at the top of the viewing area.

这在概念上类似于 Excel 中的冻结窗格"功能.但是,一个 HTML 页面中可能包含多个表,我只希望它发生在当前处于视图中的表中,并且仅在它处于视图中时发生.

This would be conceptually like the "freeze panes" feature in Excel. However, an HTML page might contain several tables in it and I only would want it to happen for the table that is currently in-view, only while it is in-view.

注意:我见过一种解决方案,其中表数据区域可滚动而标题不滚动.这不是我正在寻找的解决方案.

Note: I've seen one solution where the table data area is made scrollable while the headers do not scroll. That's not the solution I'm looking for.

推荐答案

查看 jQuery.floatThead(可用演示)非常酷,可以与DataTables一起使用也可以,甚至可以在 overflow: auto 容器内工作.

Check out jQuery.floatThead (demos available) which is very cool, can work with DataTables too, and can even work inside an overflow: auto container.

这篇关于查看大表格时,HTML 表格标题始终显示在窗口顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆