简体   繁体   中英

iPhone SE not displaying the responsive table title Correctly BUT working on Android

I borrowed code from Simple Responsive Table in CSS and Responsive Table Demo , they worked correctly on my iPhone SE as the screenshots.

CSS中的简单响应表

响应表演示

I modified the code using golang's template to implement a http server, it showed the responsive table correctly on desktop and the chrome simulated mobile screen,

手机模拟

but not on my SE.

iPhone SE RWD表

Here is my code

<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>

I've read iPhone 5 is not displaying the responsive mode of the website correctly and using google to find the solution but nothing found.

So any help is appreciated.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM