2

我已经修复了这个小提琴中给出的 html 表的列。同样,我试图只修复表格的标题行,

var $table = $('.table');
var $fixedColumn = $table.clone().insertBefore($table).addClass('fixed-column');

$fixedColumn.find('tbody').remove();

$fixedColumn.find('thead th').each(function (i, elem) {
    $(this).width($table.find('tbody tr:first td:eq(' + i + ')').width());
});

这是在这个小提琴中给出的。但是标题没有固定。什么不见​​了?

4

1 回答 1

1

这个怎么样??

演示

   <tr class="fixed">
       <th>#</th>
       <th>Table heading</th>
       <th>Table heading</th>
       <th>Table heading</th>
       <th>Table heading</th>
       <th>Table heading</th>
       <th>Table heading</th>
   </tr>

css

.fixed
{
    position:fixed;
    background:gray;

}

如果您更感兴趣,您也可以尝试这个示例!

于 2015-05-05T04:38:24.837 回答