【发布时间】:2013-10-31 06:09:01
【问题描述】:
我已经找到了几种固定标题的解决方案,但它们都不能解决我的问题。
我有一个表格,样式为 jQuery mobile(响应式表格)。此表由.append 动态填充。列没有固定的宽度,它们会有所不同。
有没有办法修复表格的标题,这样我就可以滚动表格主体,标题始终显示在顶部,但不使用多个表格。
总结:
我想要一个带有固定标题的表。
我很惊讶这没有标准,因为我认为这是大多数 webdevs 可以使用的东西。如果我错了,请纠正我。
提前谢谢你!
编辑:
例子:
<table id="my_id" data-role="table" class="ui-body-d ui-shadow table-stripe
ui-responsive">
<thead id="must_be_static">
<tr>
<th>This guy should be static</th>
<th>This guy should be static</th>
<th>This guy should be static</th>
<th>This guy should be static</th>
<th>This guy should be static</th>
</tr>
</thead>
<tbody id="id_for_content">
<tr>
<td>Dynamic content</td>
<td>Dynamic content</td>
<td>Dynamic content</td>
<td>Dynamic content</td>
<td>Dynamic content</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Foot</td>
<td>Foot</td>
<td>Foot</td>
<td>Foot</td>
<td>Foot</td>
</tr>
</tfoot>
</table>
【问题讨论】:
-
没有办法用单个表格来做到这一点(至少据我所知),这是不幸的,因为它混淆了表格标题单元格和表格数据单元格之间的语义关系。
-
仅在 HTML/CSS 中无法做到这一点,但您可以使用 jQuery 插件为您处理:fixedheadertable.com
-
我尝试使用 fixedheadertable 插件,但不幸的是,这在后台将 1 个表转换为 2 个表。所以不是我正在寻找的解决方案..
-
发布您的代码或在小提琴上重现问题。
-
给出的例子。只是你的平均表..
标签: jquery html css jquery-mobile