【发布时间】:2012-10-01 22:42:08
【问题描述】:
对不起,我的英语不好,我希望你能明白我想说的话......
我正在尝试实现一个 HTML 表格,它支持独立于表格头部滚动表格主体。
我发现以下问题对我有很大帮助: How to scroll table's "tbody" independent of "thead"?
我测试了以下代码,它可以在 Chrome (22)、Firefox (16) 和 Opera (12) 上正常运行:
HTML:
<table>
<thead>
<tr>
<th>Title1</th>
<th>Title2</th>
<!-- ... -->
</tr>
</thead>
<tbody>
<tr>
<td>...</td>
<td>...</td>
<!-- ... -->
</tr>
<!-- ... -->
</tbody>
</table>
CSS:
thead, tbody {
display: block;
}
tbody {
height:500px;
overflow-y:auto;
overflow-x:hidden;
}
thead {
line-height: 20px;
}
所以它可以在除 IE 9 之外的主要浏览器上运行,在 IE 上,我有一些问题:
- tbody 的高度未定义(所以我没有任何滚动条)
- 每个都有 500px 的高度(其他浏览器上 tbody 的高度)
以下两个示例具有完全相同的问题:http://jsfiddle.net/nyCKE/2/,http://www.imaputz.com/cssStuff/bigFourVersion.html
我看到了以下问题(和答案),但对我没有帮助:IE9 + css : problem with fixed header table
所以我确定这个错误来自 IE,但我不知道如何在不改变我的 HTML 结构的情况下修复它。
有人知道吗?
【问题讨论】:
标签: html css scroll html-table internet-explorer-9