skip to Main Content

I’m trying to add a table to my Shopify store, and current have the table setup as the following:

<div class="table-responsive">
<table style="width:100%; table-layout:fixed; border-collapse:separate !important;background-color: #f7f7f7; border-spacing:30px 5px; color:#333333; font-size:16px; line-height:12px; font-weight:100;" class="bodywrapcenter">
  <tr>
        <td> <i class="fa-solid fa-droplet"></i> Waterproof</td>
        <td> <i class="fa-solid fa-leaf"></i> Certified Vegan</td>
  </tr>
  <tr>
        <td> <i class="fa-solid fa-seedling"></i> Natural Rubber</td>
        <td> <i class="fa-solid fa-feather"></i> Light Weight</td>
  </tr>
</table></div>

However, I’m trying to make the following table show in one rows in mobile. (1 x 4 instead of 2 x 2 on mobile).

I tried adding the the following code for CSS:

.table.bodywrapcenter>tr>td {
    width: 100%;
    float: left;
}

however, It’s still not working.

Can someone please help me? I’m a newbie so detailed instruction would be greatly appreciated.

Thanks in advance!

3

Answers


  1. .table-responsive.bodywrapcenter{
        display:flex,
        flex-wrap:wrap
    }
    
    Login or Signup to reply.
  2. For the responsive design, you can use the below CSS and set your preferred style in different widths.

    @media only screen and (max-width: 390px) { //your CSS code }
    
    Login or Signup to reply.
  3. Perhaps you can do it just with <div> tags instead using table elements. If you can do it this way you can play with display: flex attribute and @mediaqueries to change the view depending on the viewport. I let you an example attached.

    .bodywrapcenter {
      width: 100%;
      display: flex;
      flex-flow: row wrap;
      background-color: #f7f7f7;
      color: #333333;
      font-size: 16px;
      line-height: 12px;
      font-weight: 100;
    }
    
    .bodywrapcenter-tr {
        display: flex;
        flex-flow: row wrap;
        flex: 0 0 50%;
    }
    
    .bodywrapcenter-td {
      display: block;
    }
    
    @media only screen and (min-width: 768px) {
      .bodywrapcenter-tr {
        flex-flow: row wrap;
         justify-content: space-around;
      }
    }
    <div class="table-responsive">
      <div class="bodywrapcenter">
        <div class="bodywrapcenter-tr">
          <div class="bodywrapcenter-td">Waterproof</div>
          <div class="bodywrapcenter-td">Certified Vegan</div>
        </div>
        <div class="bodywrapcenter-tr">
          <div class="bodywrapcenter-td">Natural Rubber</div>
          <div class="bodywrapcenter-td">Light Weight</div>
        </div>
      </div>
    </div>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search