css - 表格移动响应不起作用?

标签 css mobile html-table safari

当我改变浏览器的大小时,我有一个正确显示的表格。但是在 Safari 或 Chrome 中的移动设备上无法正常工作。我该怎么办?

@media screen and  (max-width: 1323px) {

  
  table {
   
    margin-top: 50px;
    width: 80%;
    margin-left: 10%;
    display: block;
    td {

      
      padding: 40px;
      border: 1px solid #fff;
      display: -webkit-box;
      display: -ms-flexbox;
      display: flex;
      &:before {
        content: attr(data-label) " : ";
        -webkit-box-flex: 0;
        -ms-flex: 0 0 5em;
        flex: 0 0 5em;
        font-weight: bold;
        margin-right: 1em;
        margin-bottom: 0.25em;
      }
    }

    tr {

      &:nth-child(1) {
        display: none;
      }
      &:nth-child(2) td {
        .p1 {
          &:after {
            content: attr(data-label) " $ ";
          }
          margin: 0 auto;
          display: block;
          @include format-text(23px, $footer-red-color, "Museo Sans Cyrl 300")
        }
        .p2 {
          display: none;
        }
      }
    }

    ul {
      width: 50%;
      margin: 0 auto;
      padding: 0;
      li {
        background: url(../images/list-style.png) no-repeat left center;
        padding: 14px 0px 14px 10px;
        float: left;
        @include format-text(20px, $tablet-blue-color, "Museo Sans Cyrl 300")
      }
    }
  }
}
<table>
  <tr>
    <td>A Walnut</td>
    <td>Walnut+</td>
    <td>Walnut group</td>
  </tr>
  <tr>
    <td data-label="Walnut group">
      <div class="p1">7</div>
      <div class="p2">$</div></td>
    <td data-label="Walnut group">
      <div class="p1">12</div>
      <div class="p2">$</div></td>
    <td data-label="Walnut group">
      <div class="p1">24</div>
      <div class="p2">$</div></td>
  </tr>
  <tr>
   <td data-label="Walnut group">
      <ul class="first">
        <li>Duis aute irure dolor in reprehenderit</li>
        <li>Excepteur sint occaecat cupidatat non</li>
        <li>Sed ut perspiciatis unde omnis iste</li>
      </ul></td>
    <td data-label="Walnut group">
      <ul>
        <li>Duis aute irure dolor in reprehenderit</li>
        <li>Excepteur sint occaecat cupidatat non</li>
        <li>Sed ut perspiciatis unde omnis iste</li>
        <li>Aperiam, eaque ipsa quae ab illo</li>
      </ul></td>
    <td data-label="Walnut group">
      <ul>
        <li>Duis aute irure dolor in reprehenderit</li>
        <li>Excepteur sint occaecat cupidatat non</li>
        <li>Sed ut perspiciatis unde omnis iste</li>
        <li>Aperiam, eaque ipsa quae ab illo</li>
        <li>Beatae vitae dicta sunt explicabo.</li>
      </ul></td>
  </tr>
  <tr>
   <td data-label="Walnut group">
      <button class="footer_button">Buy</button></td>
   <td data-label="Walnut group">
      <button class="footer_button">Buy</button></td>
   <td data-label="Walnut group">
      <button class="footer_button">Buy</button></td>
  </tr>
</table>

我该如何解决这个问题? 但我必须使用表。 当我更改浏览器的大小时,我有一个正确显示的表格。但是在 Safari 或 Chrome 中的移动设备上无法正常工作。我该怎么办?

img mobile

img browser

最佳答案

您可以使用 @media 查询 css 使其响应

关于css - 表格移动响应不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49305607/

相关文章:

html - 仅更改表格的一部分的背景图像

javascript - IE 兼容性错误 - CSS Javascript

css - 如何在多个 ID 或类上应用 CSS 元素属性

html - CSS 行的最后一个子元素

用于纵向方向的 CSS img srcset 媒体查询

php - 将站点重定向到移动版本,谷歌移动友好测试出错

android - 用于重定向 href 链接的 android webview backkey 中的死循环

mobile - 如何查找或搜索 FM 广播流媒体网址?

javascript - 迭代 tr 时,Jquery 不允许我选择 td 的值

jquery - 从表文本创建多维数组