【问题标题】:Table Cells Overlapp on Small Screens小屏幕上的表格单元格重叠
【发布时间】:2018-08-05 18:59:48
【问题描述】:

https://dev.meteo.cam/pricing 表格上的单元格在小屏幕上重叠:

当然,这个表格有点特别,因为我改变了样式,使得tbody 可以垂直滚动。

然而,令人困惑的是下面的代码示例使用相同的 CSS 样式:

table.table-complex {
  width: 200px;
  /*added only for this snippet to simulate small screens*/
}

table.table-complex tbody {
  display: block;
  max-height: calc(100vh - 100px);
  overflow: auto;
}

table.table-complex tbody tr,
table.table-complex thead {
  border-bottom: 1px solid #ccc;
  display: table;
  table-layout: fixed;
  white-space: normal;
  width: 100%;
}
<table class="table-complex">
  <thead>
    <tr>
      <th>Webcam</th>
      <th>Price</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>FTP upload <small>(up to every 5 min)</small><sup>1</sup></td>
      <td><b>free</b></td>
    </tr>
    <tr>
      <td>RapidFire FTP upload: <small>(up to every 5 sec)</small><sup>1</sup></td>
      <td><b>USD 0.99</b> <small>/month</small></td>
    </tr>
    <tr>
      <td>Archive <small>(10 years)</small><sup>2</sup></td>
      <td><b>USD 1.99</b> <small>/month</small></td>
    </tr>
  </tbody>
</table>

为什么上面的示例可以工作,但在小屏幕上的 https://dev.meteo.cam/pricing 上却不行?

PS:当我通过 Chrome Inspector 在 https://dev.meteo.cam/pricing 上插入 CSS 时,它也可以工作!

【问题讨论】:

  • 它正在工作..没有重叠问题..您是否检查了真实设备或 chrome 响应工具

标签: css html-table whitespace tablelayout


【解决方案1】:

我在浏览器中检查了它,table.table-complex td 有一个 white-space:nowrap 样式元素。这导致了您遇到的问题。它是tags.css 文件的一部分。

【讨论】:

  • 谢谢,就在这一刻,我还看到了这种用于小屏幕的额外 CSS 样式...
猜你喜欢
  • 2017-08-09
  • 1970-01-01
  • 2023-03-26
  • 1970-01-01
  • 1970-01-01
  • 2014-01-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多