我發現了一個固定頭的幾個解決方案,但他們都不會解決我的問題。固定表頭與動態內容?
我有一個表,用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>
沒有辦法用單個表(至少據我所知)這樣做,這是不幸的,因爲它混淆了表格標題單元格和表格數據單元格之間的語義關係。 –
在HTML/CSS中沒有辦法做到這一點,但你可以使用jQuery插件來爲你處理它:http://fixedheadertable.com/ – ediblecode
我試圖使用fixedheadertable插件,但不幸的是,這將1個錶轉換爲背景中有2張桌子。所以不是我正在尋找的解決方案.. – Billy