【问题标题】:How to make a large table responsive如何使大表响应
【发布时间】:2018-03-30 16:29:55
【问题描述】:

我的表格在桌面上显示良好,但是一旦我尝试查看移动版本,我的表格最终对于移动设备屏幕来说太宽了。我正在使用响应式布局。 如何设置此表在手机中正常显示 这是我的代码

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<div class="row clearfix">
    <div class="col-xs-12">
        <div class="card">
            <div class="body">
                <div class="table-responsive">
                    <table id="myTable" class="table table-bordered table-striped table-hover js-basic-example dataTable">
                        <thead>
                            <tr>
                                <th>Name</th>
                                <th>Position</th>
                                <th>Office</th>
                                <th>Age</th>
                                <th>Start date</th>
                                <th>Salary</th>
                            </tr>
                        </thead>
                        <tr>
                            <th>Name</th>
                            <th>Position</th>
                            <th>Office</th>
                            <th>Age</th>
                            <th>Start date</th>
                            <th>Salary</th>
                        </tr>
                    </table>

                </div>
            </div>
        </div>
    </div>
    </div>

【问题讨论】:

标签: html css responsive-design html-table


【解决方案1】:

朋友们,不要试图与金融争斗。也许您可以使用媒体查询隐藏不太重要的列,显示 3 而不是 6

【讨论】:

    【解决方案2】:

    另一个选项可能是通过添加 overflow-x:auto 来启用表格的水平滚动;到父 div 的样式表。

    div.table-responsive {
      overflow-x:auto;
    }
    

    【讨论】:

      猜你喜欢
      • 2012-03-17
      • 2017-09-13
      • 2017-08-02
      • 2018-05-18
      • 2015-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-13
      相关资源
      最近更新 更多