固定表头与动态内容?

问题描述 投票:4回答:2

我发现了一个固定的头几个解决方案,但没有人会解决我的问题。

我有一个表,使用jQuery移动(响应表)风格。此表是动态填充.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>
jquery html css jquery-mobile
2个回答
0
投票

您是否正在寻找这样的事情::

http://jsfiddle.net/h5t98/

    <table border="1">
  <thead>
    <tr>
      <th class="month">Month</th>
      <th class="saving">Savings</th>
    </tr>
  </thead>
  <tfoot>
    <tr>
      <td>Sum</td>
      <td>$180</td>
    </tr>
  </tfoot>
  <tbody>
    <tr>
      <td>February</td>
      <td>$80</td>
    </tr>
      <tr>
      <td>January</td>
      <td>$100</td>
    </tr>
  </tbody>
</table>

0
投票

也许下面http://www.datatables.net/extras/fixedheader/会为你工作?

© www.soinside.com 2019 - 2024. All rights reserved.