首页 > 解决方案 > css表在页面上没有响应

问题描述

我的网站上有一张桌子,里面有产品卡片,效果很好,但在手机上,它没有显示为响应式。这是链接:Marcos-backyard-swimming.herokuapp.com/#work

表格(在移动设备上)似乎溢出了该页面的宽度,而在计算机上则非常好......不知道为什么,但这是代码

我的表格代码如下:

  @media screen and (min-width: 600px) {
  .product-card {
    width: 380px;
    position: relative;
    box-shadow: 0 2px 7px #dfdfdf;
    margin: 5px auto;
    background: #fafafa;
} 
}
@media screen and (max-width: 600px) {
  .product-card {
    width: 280px;
    position: relative;
    box-shadow: 0 2px 7px #dfdfdf;
    margin: 5px auto;
    background: #fafafa;
} 
}
.badge {
    position: absolute;
    left: 0;
    top: 20px;
    text-transform: uppercase;
    font-size: 13px;
    font-weight: 700;
    background: red;
    color: #fff;
    padding: 3px 10px;
}

.product-tumb {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 300px;
    padding: 50px;
    background: #fff;
}

.product-tumb img {
    max-width: 100%;
    max-height: 100%;
}

.product-details {
    padding: 30px;
}

.product-catagory {
    display: block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: #ccc;
    margin-bottom: 18px;
}

.product-details h4 a {
    font-weight: 500;
    display: block;
    margin-bottom: 18px;
    text-transform: uppercase;
    color: #363636;
    text-decoration: none;
    transition: 0.3s;
}

.product-details h4 a:hover {
    color: #fbb72c;
}

.product-details p {
    font-size: 15px;
    line-height: 22px;
    margin-bottom: 18px;
    color: #999;
}

.product-bottom-details {
    overflow: hidden;
    border-top: 1px solid #eee;
    padding-top: 20px;
}

.product-bottom-details div {
    float: left;
    width: 50%;
}

.product-price {
    font-size: 18px;
    color: #fbb72c;
    font-weight: 600;
}

.product-price small {
    font-size: 80%;
    font-weight: 400;
    text-decoration: line-through;
    display: inline-block;
    margin-right: 5px;
}

.product-links {
    text-align: right;
}

.product-links a {
    display: inline-block;
    margin-left: 5px;
    color: #e1e1e1;
    transition: 0.3s;
    font-size: 17px;
}

.product-links a:hover {
    color: #fbb72c;
}

#######################

  table {
    width: 100px;
    margin:0;
    padding:0;
    border-collapse: collapse;
    border-spacing: 0;
  }

  table tr {
    padding: 5px;
  }

  table th, table td {
    padding: 10px;
    text-align: center;
    border: 3px solid transparent;
  }

  table th {
    text-transform: uppercase;
    font-size: 14px;
    letter-spacing: 1px;
  }

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

    table {
      border: 0;
    }

    table thead {
      display: none;
    }

    table tr {
      margin-bottom: 10px;
      display: block;
      border-bottom: 2px solid #ddd;
    }

    table td {
      display: block;
      text-align: right;
      font-size: 13px;
      border-bottom: 1px dotted #ccc;
    }

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

    table td:before {
      content: attr(data-label);
      float: left;
      text-transform: uppercase;
      font-weight: bold;
    }
  }
<table class="center">
          <style>
            .center {
      margin-left: auto;
      margin-right: auto;
    }
          </style>
          <!-- row 1 -->
         <td>
        <div class="product-card">
          <div class="product-tumb">
            <img src="https://res.cloudinary.com/piersolutions/image/upload/v1611681750/LIFEGUARDBEACH_diaxa1.jpg" alt="Certified Instructors provide the leadership for levels your child is completing and for future courses. Examiner evaluates and teaches students of all ages in depth through all their levels.">
        </div>
        <div class="product-details">
            <h4 style="text-align: center;"><a href="#work">Lifesaving Instructor Certified</a></h4>
        </div>
        </div>
    </td>
    <td>
      <div class="product-card">
        <div class="product-tumb">
          <img src="https://res.cloudinary.com/piersolutions/image/upload/v1611681755/bronze-med_v2aetz.jpg" alt="Certified Instructors provide the leadership for levels your child is completing and for future courses. Examiner evaluates and teaches students of all ages in depth through all their levels.">
      </div>
      <div class="product-details">
          <h4 style="text-align: center;"><a href="#work">Bronze Med Certified</a></h4>
      </div>
    </div>
    </td>
    <td>
      <div class="product-card">
        <div class="product-tumb">
          <img src="https://res.cloudinary.com/piersolutions/image/upload/v1611681752/bronze-cross_ekodzr.jpg" alt="Certified Instructors provide the leadership for levels your child is completing and for future courses. Examiner evaluates and teaches students of all ages in depth through all their levels.">
      </div>
      <div class="product-details">
          <h4 style="text-align: center;"><a href="#work">Bronze Cross Certified</a></h4>
      </div>
    </div>
    </td>
    <!-- row 2 -->
    <tr>
      <td>
        <div class="product-card">
          <div class="product-tumb">
            <img src="https://images.pexels.com/photos/5664736/pexels-photo-5664736.jpeg?auto=compress&cs=tinysrgb&dpr=2&w=500" alt="Certified Instructors provide the leadership for levels your child is completing and for future courses. Examiner evaluates and teaches students of all ages in depth through all their levels.">
        </div>
        <div class="product-details">
            <h4 style="text-align: center;"><a href="#work">First Aid Certified</a></h4>
        </div>
      </div>
      </td>
      <td>
        <div class="product-card">
          <div class="product-tumb">
            <img src="https://res.cloudinary.com/piersolutions/image/upload/v1614817177/IMG_5382_tgbctx.jpg" alt="Certified Instructors provide the leadership for levels your child is completing and for future courses. Examiner evaluates and teaches students of all ages in depth through all their levels.">
        </div>
        <div class="product-details">
            <h4 style="text-align: center;"><a href="#work">First Aid Instructor Certified</a></h4>
        </div>
      </div>
      </td>
      <td>
        <div class="product-card">
          <div class="product-tumb">
            <img src="https://res.cloudinary.com/piersolutions/image/upload/v1614817231/IMG_8125_ioeocc.jpg" alt="Certified Instructors provide the leadership for levels your child is completing and for future courses. Examiner evaluates and teaches students of all ages in depth through all their levels.">
        </div>
        <div class="product-details">
            <h4 style="text-align: center;"><a href="#work">Instructor Certified</a></h4>
        </div>
      </div>
      </td>
    </tr>
    <!-- row 3 -->
    <tr>
      <td>
        <div class="product-card">
          <div class="product-tumb">
            <img src="https://res.cloudinary.com/piersolutions/image/upload/v1615177045/instructor_n4ijyg.png" alt="Certified Instructors provide the leadership for levels your child is completing and for future courses. Examiner evaluates and teaches students of all ages in depth through all their levels.">
        </div>
        <div class="product-details">
            <h4 style="text-align: center;"><a href="#work">Lifesaving Society Certified Examiner</a></h4>
        </div>
      </div>
      </td>
      <td>
        <div class="product-card">
          <div class="product-tumb">
            <img src="https://res.cloudinary.com/piersolutions/image/upload/v1614817347/IMG_0123_u3umiv.png" alt="Certified Instructors provide the leadership for levels your child is completing and for future courses. Examiner evaluates and teaches students of all ages in depth through all their levels.">
        </div>
        <div class="product-details">
            <h4 style="text-align: center;"><a href="#work">CPR Certified</a></h4>
        </div>
      </div>
      </td>
      <td>
        <div class="product-card">
          <div class="product-tumb">
            <img src="https://res.cloudinary.com/piersolutions/image/upload/v1615177046/IMG_2214_aldalj.png" alt="Certified Instructors provide the leadership for levels your child is completing and for future courses. Examiner evaluates and teaches students of all ages in depth through all their levels.">
        </div>
        <div class="product-details">
            <h4 style="text-align: center;"><a href="#work">CPR w AED skills</a></h4>
        </div>
      </div>
      </td>
    </tr>
    <tr>
    
      <td>
        <div class="product-card">
          <div class="product-tumb">
            <img src="https://res.cloudinary.com/piersolutions/image/upload/v1614817431/StandardFirstAidwCPR-C-store_7a3be70ae2700bdbeb8b2d32383cb786_qdj85s.jpg" alt="Emergency First Aid with CPR-B">
        </div>
        <div class="product-details">
            <h4 style="text-align: center;"><a href="#work">Standard First Aid with CPR-A Certified</a></h4>
        </div>
      </div>
       
      </td>
      <td>
        <div class="product-card">
          
          <div class="product-tumb">
            <img src="https://res.cloudinary.com/piersolutions/image/upload/v1614817388/IMG_6579_yg3nop.jpg" alt="Emergency First Aid with CPR-B">
        </div>
        <div class="product-details">
            <h4 style="text-align: center;"><a href="#work">Emergency First Aid with CPR-B Certified</a></h4>
        </div>
      </div>
      </td>
    </tr>
      <!-- row 3 -->
    
      </table>

  

标签: htmlcss

解决方案


推荐阅读