【问题标题】:Responsive table html - inline product title响应式表格 html - 内联产品标题
【发布时间】:2018-11-03 22:12:28
【问题描述】:

我正在开发一个电子商务网站,在购物车页面中,我有一个表格,用户可以在其中找到他添加到购物车中的所有商品,但是当我在手机中显示该网站时,所有信息都在购物车表太压缩,所以我想将产品名称放在 CSS 中的图像下方。 如果有人可以帮助我,那就太好了。

<div class="container-table-cart pos-relative">
        <div class="wrap-table-shopping-cart bgwhite">
          <table class="table-shopping-cart">
            <tr class="table-head">
              <th class="column-1"></th>
              <th class="column-2">{{ 'cart.general.heading_product_name' | t }}</th>
              <th class="column-3">{{ 'cart.general.heading_unit_price' | t }}</th>
              <th class="column-4 p-l-70">{{ 'cart.general.heading_quantity' | t }}</th>
              <th class="column-5">{{ 'cart.general.heading_total' | t }}</th>
            </tr>
            {% for item in cart.items %}
            <tr class="table-row" data-line="{{ forloop.index }}">
              <td class="column-1">
                <div class="cart-img-product b-rad-4 o-f-hidden">
                  <a href="{{ item.url }}">
                    <img src="{{ item | img_url: '90x120' }}"  alt="{{ item.title | escape }}" title="{{ item.title | escape }}" class="" />
                  </a>
                </div>
              </td>
              <td class="column-2">
                <a href="{{ item.url }}">{{ item.product.title }}</a>
                {% unless item.variant.title contains 'Default' %}
                <br />
                <small>{{ item.variant.title }}</small>
                {% endunless %}

                {% if settings.product_quantity_message and item.variant.inventory_management and item.variant.inventory_quantity <= 0 and item.variant.incoming %}
                {% assign date = item.variant.next_incoming_date | date: format: 'month_day_year' %}
                <br />
                <small>{{ 'products.product.will_not_ship_until' | t: date: date }}</small>
                {% endif %}

                {% assign property_size = item.properties | size %}
                {% if property_size > 0 %}
                {% for p in item.properties %}
                {% if forloop.first %}<br>{% endif %}
                {% unless p.last == blank %}
                {{ p.first }}:

                {% if p.last contains '/uploads/' %}
                <a href="{{ p.last }}">{{ p.last | split: '/' | last }}</a>
                {% else %}
                {{ p.last }}
                {% endif %}

                <br>
                {% endunless %}
                {% endfor %}
                {% endif %}
              </td>
              <td class="column-3">{{ item.price | money }}</td>
              <td class="column-4">
                <div class="flex-w bo5 of-hidden w-size17">
                  <button class="btn-num-product-down color1 flex-c-m size7 bg8 eff2">
                    <i class="fs-12 fa fa-minus" aria-hidden="true"></i>
                  </button>
                  <input type="number" name="updates[]" id="updates_{{ item.id }}" value="{{ item.quantity }}" min="0" class="size8 m-text18 t-center num-product" data-line="{{ forloop.index }}">
                  <button class="btn-num-product-up color1 flex-c-m size7 bg8 eff2">
                    <i class="fs-12 fa fa-plus" aria-hidden="true"></i>
                  </button>
                </div>
              </td>
              <td class="column-5">{{ item.line_price | money }}</td>
            </tr>
            {% endfor %}
          </table>

【问题讨论】:

    标签: html css html-table responsive


    【解决方案1】:

    你可以尝试做这样的事情:

    .table-center {
      text-align: center;
      vertical-align: center;
    }
    
    table a {
      text-decoration: none;
      color: black;
      display: block;
    }
    
    .table-center td {
      width: 300px;
    }
    
    @media only screen and (min-width: 300px) and (max-width: 723px) {
      .table-center td > input {
        width: 100px;
      }
      
      .table-center img {
        width: 50px;
        height: auto;
      }
      
      .table-center a {
        font-size: 0.8rem;
      }
    }
    <table class="table-center">
      <tr>
        <th>Prix</th>
        <th>Unitare</th>
        <th>Total</th>
      <tr>
      <tr>
        <td>
          <img src="https://via.placeholder.com/150C/O https://placeholder.com/">
          <a href="#">FENTY BEAUTY - Gloss Bomb Stunna</a>
        </td>
        <td>
          $30.99
        </td>
        <td>
          <input type="number">
        </td>
      </tr>
    </table>

    另外,这是working example :)

    【讨论】:

      【解决方案2】:

      你可以做的是使用媒体查询

      您可以将标题与图像放在同一列中,但在标题元素上保留 display:none 直到达到移动尺寸,在这种情况下您会再次显示它,但 display:none 在另一列中显示标题.

      例子:

      <td class=“column1”>
      <img>
      <div class=“title”>Title here</div>
      </td>
      
      <td class=“column2”>
      <div class=“col2title”>Title here</div>
      </td>
      
      @media only screen and (max-width: 600px) {
      .title {
      display: block;
      }
      .column2{
      display:none;
      }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-11-15
        • 2013-11-07
        • 1970-01-01
        • 2015-01-03
        • 1970-01-01
        • 2021-04-28
        • 1970-01-01
        相关资源
        最近更新 更多