固定表格标题与动态内容?

Bil*_*lly 5 html css jquery jquery-mobile

我找到了几种固定标头的解决方案,但没有一个能解决我的问题。

我有一个表格,采用 jQuery mobile(响应式表格)设计。该表是动态填充的.append。列没有固定的宽度,它们是变化的。有没有办法修复表格的标题,以便我能够滚动表格主体,标题始终显示在顶部,但不使用多个表格。

概括:

我想要一个带有固定标题的表。

我很惊讶没有这方面的标准,因为我认为这是大多数网络开发人员都可以使用的东西。如果我错了,请纠正我。

先感谢您!

编辑:

例子:

<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>
Run Code Online (Sandbox Code Playgroud)

小智 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>
Run Code Online (Sandbox Code Playgroud)