如何让桌子的身体滚动但保持其头部固定到位? [英] How can I let a table's body scroll but keep its head fixed in place?
问题描述
我正在编写一个页面,我需要一个 HTML 表格来保持设定的大小.我需要表格顶部的标题始终保持在那里,但无论向表格添加多少行,我还需要表格主体滚动.想想一个迷你版的 excel.这似乎是一项简单的任务,但我在网上找到的几乎所有解决方案都有一些缺点.我该如何解决这个问题?
I am writing a page where I need an HTML table to maintain a set size. I need the headers at the top of the table to stay there at all times but I also need the body of the table to scroll no matter how many rows are added to the table. Think a mini version of excel. This seems like a simple task but almost every solution I have found on the web has some drawback. How can I solve this?
推荐答案
我必须找到相同的答案.我发现的最好的例子是 http://www.cssplay.co.uk/menu/tablescroll.html - 我发现示例 #2 对我来说效果很好.你必须用Java Script设置内表的高度,其余的是CSS.
I had to find the same answer. The best example I found is http://www.cssplay.co.uk/menu/tablescroll.html - I found example #2 worked well for me. You will have to set the height of the inner table with Java Script, the rest is CSS.
这篇关于如何让桌子的身体滚动但保持其头部固定到位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!