html - iPhone SE 无法正确显示响应表标题,但可以在 Android 上运行

标签 html ios css responsive

我从Simple Responsive Table in CSS借来代码和 Responsive Table Demo , 它们在我的 iPhone SE 上正常工作,如屏幕截图所示。

Simple Responsive Table in CSS

Responsive Table Demo

我使用golang的模板修改了代码,实现了一个http服务器,它在桌面和chrome模拟的移动屏幕上正确显示了响应表,

Mobile simulated

但不在我的 SE 上。

iPhone SE RWD table

这是我的代码

<head>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <style>
    body {
      font-family: "Open Sans", sans-serif;
      line-height: 1.25;
    }

    table {
      border: 1px solid #ccc;
      border-collapse: collapse;
      margin: 0;
      padding: 0;
      width: 100%;
      table-layout: fixed;
    }

    table caption {
      font-size: 1.5em;
      margin: .5em 0 .75em;
    }

    table tr {
      background-color: #f8f8f8;
      border: 1px solid #ddd;
      padding: .35em;
    }

    table th,
    table td {
      padding: .625em;
      text-align: center;
    }

    table th {
      font-size: .85em;
      letter-spacing: .1em;
      text-transform: uppercase;
    }

    /* iPhone 5 Retina regardless of IOS version */
    @media (device-height : 568px) and (device-width : 320px) and (-webkit-min-device-pixel-ratio: 2)

    /* and (orientation : todo: you can add orientation or delete this comment)*/
      {

    /*IPhone 5 only CSS here*/
      table {
        border: 0;
      }

      table caption {
        font-size: 1.3em;
      }

      table thead {
        border: none;
        clip: rect(0 0 0 0);
        height: 1px;
        margin: -1px;
        overflow: hidden;
        padding: 0;
        position: absolute;
        width: 1px;
      }

      table tr {
        border-bottom: 3px solid #ddd;
        display: block;
        margin-bottom: .625em;
      }

      table td {
        border-bottom: 1px solid #ddd;
        display: block;
        font-size: .8em;
        text-align: right;
      }

      table td::before {
        content: attr(data-label);
        float: left;
        font-weight: bold;
        text-transform: uppercase;
      }

      table td:last-child {
        border-bottom: 0;
      }
    }


    @media screen and (max-width: 500px) {
      table {
        border: 0;
      }

      table caption {
        font-size: 1.3em;
      }

      table thead {
        border: none;
        clip: rect(0 0 0 0);
        height: 1px;
        margin: -1px;
        overflow: hidden;
        padding: 0;
        position: absolute;
        width: 1px;
      }

      table tr {
        border-bottom: 3px solid #ddd;
        display: block;
        margin-bottom: .625em;
      }

      table td {
        border-bottom: 1px solid #ddd;
        display: block;
        font-size: .8em;
        text-align: right;
      }

      table td::before {

        content: attr(data-label);
        float: left;
        font-weight: bold;
        text-transform: uppercase;
      }

      table td:last-child {
        border-bottom: 0;
      }
    }
  </style>
</head>

<body style="background: rgb(29, 29, 29)">

  <table>
    <caption>Statement Summary</caption>
    <thead>
      <tr>
        <th scope="col">Account</th>
        <th scope="col">Due Date</th>
        <th scope="col">Amount</th>
        <th scope="col">Period</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td data-label="Account">Visa - 3412</td>
        <td data-label="Due Date">04/01/2016</td>
        <td data-label="Amount">$1,190</td>
        <td data-label="Period">03/01/2016 - 03/31/2016</td>
      </tr>
      <tr>
        <td scope="row" data-label="Account">Visa - 6076</td>
        <td data-label="Due Date">03/01/2016</td>
        <td data-label="Amount">$2,443</td>
        <td data-label="Period">02/01/2016 - 02/29/2016</td>
      </tr>
      <tr>
        <td scope="row" data-label="Account">Corporate AMEX</td>
        <td data-label="Due Date">03/01/2016</td>
        <td data-label="Amount">$1,181</td>
        <td data-label="Period">02/01/2016 - 02/29/2016</td>
      </tr>
      <tr>
        <td scope="row" data-label="Acount">Visa - 3412</td>
        <td data-label="Due Date">02/01/2016</td>
        <td data-label="Amount">$842</td>
        <td data-label="Period">01/01/2016 - 01/31/2016</td>
      </tr>
    </tbody>
  </table>
</body>

我读过 iPhone 5 is not displaying the responsive mode of the website correctly并使用谷歌查找解决方案,但没有找到。

因此,我们将不胜感激任何帮助。

最佳答案

*@media (device-height : 568px) and (device-width : 320px) and (-webkit-min-device-pixel-ratio: 2)*

问题是device-height,真正的iphone-se的device-height应该小于568px,因为它不包括safari的页眉和页脚

关于html - iPhone SE 无法正确显示响应表标题,但可以在 Android 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57941673/

相关文章:

html - 在 Rails 中呈现 View 后评估代码

iphone - Facebook 应用程序中的 titleView 图标(像那样绘制的算法?)

javascript - 滚动顶部动画在 IOS 上不工作

html - 调整窗口大小时停止图像抖动

javascript - jQuery 侧边栏菜单背景不会隐藏单击外部

CSS Roll Over with Sprites & 滑动门

jquery - 在自定义内容 slider 中滑动时出现空白/间隙问题

javascript - 从按钮(不是导航栏)链接到 Bootstrap 部分 ID

ios - 使用 ARC 时无法从一个类调用方法到另一个类

javascript - 我在使用复选框时遇到问题