我需要一些帮助。我尝试了 2 天来制作一个带有 tbody 的可滚动表格,但我找不到解决方案。
我的 table 是:
<table width=100% style="margin:0 0 0 -1px; border-collapse:collapse;">
<thead>
<tr>
<th ><input type="checkbox" id="select_all" /></th>
<c:forEach items="${grid.heads}" var="element">
<th><c:out value="${element.id}"/></th>
</c:forEach>
</tr>
</thead>
<tbody style="height:200px !important; overflow: auto; display:block;">
<nested:iterate id="row" name="grid" property="data" indexId="cnt">
<tr>
<td><input type="checkbox" name="list_with_checkboxes" value=<c:out value="${row[0]}"/> ></td>
<nested:iterate id="element" name="row">
<td><c:out value="${element}"/> </td>
</nested:iterate>
</tr>
</nested:iterate>
</tbody>
</table>
我的表格呈现正确但我不能使 tbody 可滚动,因为我不知道为什么 tbody 有另一个高度然后 200px。
有什么想法吗?非常感谢!
最佳答案
似乎已经有很多答案了
How can I let a table's body scroll but keep its head fixed in place?
<th style="width:0px;"></th>
这个现有的 fiddle 似乎可以解决它,但请查看上面链接中的其他建议- http://jsfiddle.net/venkateshwar/X8FSw/17/show/
关于jquery - IE8 中带有固定标题的表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20217146/