小编Vic*_*Vic的帖子

修复Bootstrap表的第一列

我在这篇文章中关注了@ koala_dev的代码,试图锁定我的表水平滚动的第一列.不幸的是,代码对我的表没有影响.我想知道是否有人可以给我一些关于我做错了什么的指示,因为我是编程新手.

这是我的桌子:http: //jsfiddle.net/mademoiselletse/bypbqboe/59/

这是我在JS中插入的代码(第121-133行):

$(function() {
    var $tableClass = $('.table');
    // Make a clone of our table
    var $fixedColumn = $tableClass.clone().insertBefore($tableClass).addClass('fixed-column');

    // Remove everything except for first column
    $fixedColumn.find('th:not(:first-child),td:not(:first-child)').remove();

    // Match the height of the rows to that of the original table's
    $fixedColumn.find('tr').each(function(i, elem) {
      $(this).height($tableClass.find('tr:eq(' + i + ')').height());
    });
});
Run Code Online (Sandbox Code Playgroud)

这是我插入的CSS属性(第36-47行):

.table-responsive > .fixed-column {
   position: absolute;
   display: inline-block;
   width: auto;
   border-right: 1px solid #ddd;
}

@media(min-width:768px) {
    .table-responsive>.fixed-column {
        display: none;
    } …
Run Code Online (Sandbox Code Playgroud)

javascript css bootstrap-table

18
推荐指数
2
解决办法
5万
查看次数

标签 统计

bootstrap-table ×1

css ×1

javascript ×1