【问题标题】:DIV Scroll working for one table but not working for another tableDIV Scroll 适用于一张桌子但不适用于另一张桌子
【发布时间】:2017-03-20 21:35:41
【问题描述】:

有人可以看看这个问题吗?

滚动条显示一个表格,而另一个表格没有显示,该表格由相同的 CSS 和 HTML 文件组成。

顶部表格滚动条不显示,但底部表格显示

HTML 表格不显示滚动

<div class="wrapper">
    <table class="professional">
      <tbody>
        <tr>
          <th class="tableheader" ng-show="accountInfo.accountId > 0">Account Number</th>
          <th class="tableheader" ng-show="accountInfo.accountId > 0" >First Name</th>
          <th class="tableheader" ng-show="accountInfo.accountId > 0">Last Name</th>
          <th class="tableheader" ng-show="accountInfo.accountId > 0">Status</th>
          <th class="tableheader" ng-show="accountInfo.accountId > 0">Services</th>
          <th class="tableheader" ng-show="accountInfo.accountId > 0">Suspend Status</th>
          <th class="tableheader" ng-show="accountInfo.accountId > 0">Phone Number</th>
          <th class="tableheader" ng-show="accountInfo.accountId > 0">Activation Code</th>
          <th class="tableheader" ng-show="accountInfo.accountId > 0">SSO ID</th>
        </tr>
        <tr>
          <td class="features" >{{accountInfo.accountId}}</td>
          <td class="features" >{{accountInfo.firstName}}</td>
          <td class="features" >{{accountInfo.lastName}}</td>
          <td class="features" >{{accountInfo.status}}</td>
          <td class="features" >{{accountInfo.group}}</td>
          <td class="features" >{{accountInfo.suspended}}</td>
          <td class="features" >{{accountInfo.homePhone}}</td>
          <td class="features" >{{accountInfo.activationCode}}</td>
          <td class="features" >{{accountInfo.guid}}</td>
        </tr>
      </tbody>
    </table>
</div>

显示滚动的 HTML 表格

<div class="wrapper">
    <table class="professional">
      <tbody>
        <tr>
          <th class="tableheader" ng-repeat="list in cellularIPAddressValue">{{list.deviceType}}
          </th>
        </tr>
        <tr>
          <td class="features" ng-repeat="list in cellularIPAddressValue">{{list.instanceId}}
          </td>
        </tr>
        <tr>
          <td class="features" ng-repeat="list in cellularIPAddressValue">{{list.firmwareVersion}}
          </td>
        </tr>
        <tr>
          <td class="features" ng-repeat="list in cellularIPAddressValue">{{list.manufacturer}}
          </td>
        </tr>
        <tr>
          <td class="features" ng-repeat="list in cellularIPAddressValue">{{list.model}}
          </td>
        </tr>
        <tr>
          <td class="features" ng-repeat="list in cellularIPAddressValue">
            {{list.troubles[0].description}}
            <p ng-show="list.troubles[0]">Failure On {{list.troubles[0].date}}
            </p>
          </td>
        </tr>
      </tbody>
    </table>
</div>

CSS:

.wrapper {
    overflow: scroll;
    width: 1350px;
    white-space: nowrap;
    padding-bottom: 10px;
    padding-top: 10px;
}

.professional .title {
    padding-top: 10px;
    background: #2980b9;
}

.professional .tableheader, .professional .pt-footer {
    background: #2980b9;
}

.professional .tableheader:after {
    border-top-color: #2980b9;
}

.professional .pt-footer:after {
    border-top-color: #FFFFFF;
}

【问题讨论】:

  • 似乎第一个表没有足够的数据滚动。您需要更多标题和内容才能看到滚动
  • 如果你看到第一个表标题在同一页面内缩小,它就有足够的数据

标签: html css scroll html-table overflow


【解决方案1】:

我已经找到了解决上述问题的方法。

通过如下修改 CSS 更正

所以我添加了white-space : nowrap,因此内容现在看起来不错,滚动条具有相同的数据而不会缩小

 .wrapper {
         overflow : auto;
         width: 1350px;
         white-space: nowrap;
         padding-bottom : 10px;
         padding-top : 10px;
    }

    .th {
        text-align: center;
        -webkit-border-radius: 10px;
        -moz-border-radius: 10px;
        border-radius: 10px;
        width : auto;
        height : word-spacing;
    white-space: nowrap;

    }

    .td {
        white-space: nowrap;
        border-style: solid;
        border-right-color: #ff0000;
    }

【讨论】:

    【解决方案2】:

    表格是否在同一页上?如果是,请将表类更改为其他内容:

    <table class="professional"> for table 1
    <table class="professional2"> for table 2
    

    表 1 的 CSS:

    .professional .title {
        padding-top: 10px;
        background: #2980b9;
    }
    
    .professional .tableheader, .professional .pt-footer {
        background: #2980b9;
    }
    
    .professional .tableheader:after {
        border-top-color: #2980b9;
    }
    
    .professional .pt-footer:after {
        border-top-color: #FFFFFF;
    }
    

    表 2 的 CSS:

    .professional2 .title {
        padding-top: 10px;
        background: #2980b9;
    }
    
    .professional2 .tableheader, .professional .pt-footer {
        background: #2980b9;
    }
    
    .professional2 .tableheader:after {
        border-top-color: #2980b9;
    }
    
    .professional2 .pt-footer:after {
        border-top-color: #FFFFFF;
    }
    

    【讨论】:

    • 两者都存在于同一个 HTML 页面中,但我们可以为多个表格设置同一个类。
    猜你喜欢
    • 2011-02-20
    • 1970-01-01
    • 1970-01-01
    • 2011-10-09
    • 2020-07-29
    • 2012-05-23
    • 1970-01-01
    • 2019-02-25
    • 2015-06-20
    相关资源
    最近更新 更多