【问题标题】:How can I fix the last two columns of a bootstrap responsive table?如何修复引导响应表的最后两列?
【发布时间】:2017-08-11 11:59:36
【问题描述】:

我想修复响应式表格中的最后两列,但我的代码中有一些错误:

http://jsfiddle.net/4XG7T/1961/

 
    var $table = $('.table');
    var $fixedColumn = $table.clone().insertBefore($table).addClass('fixed-column');
    
    $fixedColumn.find('th').slice(-4).remove();
    
    $fixedColumn.find('tr').each(function (i, elem) {
        $(this).height($table.find('tr:eq(' + i + ')').height());
    });
    .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;
        }
    }
   
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    
    
    <div class="table-responsive">
        <table class="table table-striped table-bordered table-hover">
            <thead>
                <tr>
                    <th>#</th>
                    <th>Table heading</th>
                    <th>Table heading</th>
                    <th>Table heading</th>
                    <th>Table heading</th>
                    <th>Fix this</th>
                    <th>Fix this</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>1</td>
                    <td>Table cell</td>
                    <td>Table cell</td>
                    <td>Table cell</td>
                    <td>Table cell</td>
                    <td>Last</td>
                    <td>Last</td>
                </tr>
                <tr>
                    <td>2</td>
                    <td>Table cell</td>
                    <td>Table cell</td>
                    <td>Table cell</td>
                    <td>Table cell</td>
                    <td>Last</td>
                    <td>Last</td>
                </tr>
                <tr>
                    <td>3</td>
                    <td>Table cell</td>
                    <td>Table cell</td>
                    <td>Table cell</td>
                    <td>Table cell</td>
                    <td>Last</td>
                    <td>Last</td>
                </tr>
            </tbody>
        </table>
    </div>
    
    

【问题讨论】:

  • 您的.table-responsive&gt;.fixed-column 没有在父级中设置位置。使用left/top

标签: jquery twitter-bootstrap html-table responsive


【解决方案1】:

这是一种黑客行为。但是,它仍然有效。尝试这个。

        .bootstrap-datetimepicker-widget.dropdown-menu {
            position: fixed;
        }

玩得开心……

【讨论】:

    猜你喜欢
    • 2015-07-18
    • 1970-01-01
    • 1970-01-01
    • 2015-05-17
    • 2014-04-09
    • 2015-08-07
    • 1970-01-01
    • 1970-01-01
    • 2021-11-13
    相关资源
    最近更新 更多