我如何让表的身体滚动,但保持其头部固定到位? [英] How can I let a table's body scroll but keep its head fixed in place?
问题描述
我在写一个页面,其中需要一个HTML表格来保持一个集合的大小。我需要在表的顶部的头始终保持在那里,但我还需要表的主体滚动,无论多少行添加到表。认为excel的mini版本。这看起来像一个简单的任务,但几乎我在网上找到的每个解决方案有一些缺点。我如何解决这个问题?
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屋!