skip to Main Content

Love how this table looks, until viewed on mobile devices. Seems to corrupt around “Web Site Design + Development” area and worsens as I scroll down. Would appreciate extra eyes on my code to see if there’s an easy fix.

See it in action https://frankidurbinbranding.com/comparison/

Here is the code:

<style>
table {
  border: 1px solid #ccc;
    border-collapse: collapse;
  margin: 0;
  padding: 0;
  width: 100%;
  table-layout: relative;
}
table caption {
  font-size: 1.5em;
  margin: .5em 0 .75em;
}
table tr {
  background: #fff;
  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;
  background-color: #f8f8f8;
}
@media screen and (max-width: 600px) {
  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: 1px solid #ddd;
    display: block;
    margin-bottom: .625em;
  }

  table td {
    border-bottom: 1px solid #ddd;
    display: block;
    font-size: .8em;
    text-align: left;
  }
  table td:before {
    /*
    * aria-label has no advantage, it won't be read inside a table
    content: attr(aria-label);
    */
    content: attr(data-label);
    float: right;
    font-weight: 300;
    text-transform: uppercase;
  }
  table td:last-child {
    border-bottom: 0;
  }
}

  table tr:nth-child(2n) {
  background-color: #f8f8f8;
}

.alternate tr {
  background-color: #fff;
}
</style>


<table>
  <thead>
    <tr>
      <th scope="col"></th>
      <th scope="col">BRAND YOU</th>
      <th scope="col">DIGITAL GLAMOUR</th>
      <th scope="col">VIP STATUS</th>
      <th scope="col">ECOMMERCE ELEGANCE</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td scope="row">Custom Logo Design</td>
      <td data-label=“BRAND&nbsp;YOU">&#9733;</td>
      <td data-label=“DIGITAL&nbsp;GLAMOUR">&#9733;</td>
      <td data-label=“VIP&nbsp;STATUS">&#9733;</td>
      <td data-label=“ECOMMERCE&nbsp;ELEGANCE">&#9733;</td>

    </tr>
    <tr>
      <td scope="row">Brand Style Guide</td>
      <td data-label=“BRAND&nbsp;YOU">&#9733;</td>
      <td data-label=“DIGITAL&nbsp;GLAMOUR">&#9733;</td>
      <td data-label=“VIP&nbsp;STATUS">&#9733;</td>
      <td data-label=“ECOMMERCE&nbsp;ELEGANCE">&#9733;</td>

    </tr>
    <tr>
      <td scope="row">Digital Asset Library</td>
      <td data-label=“BRAND&nbsp;YOU">&#9733;</td>
      <td data-label=“DIGITAL&nbsp;GLAMOUR">&#9733;</td>
      <td data-label=“VIP&nbsp;STATUS">&#9733;</td>
      <td data-label=“ECOMMERCE&nbsp;ELEGANCE">&#9733;</td>

    </tr>
    <tr>
      <td scope="row">Custom Collateral Design</td>
      <td data-label=“BRAND&nbsp;YOU">&#9733;</td>
      <td data-label=“DIGITAL&nbsp;GLAMOUR">&#9733;</td>
      <td data-label=“VIP&nbsp;STATUS">&#9733;</td>
      <td data-label=“ECOMMERCE&nbsp;ELEGANCE">&#9733;</td>    
    </tr>
       <tr>
      <td scope="row">Website Design &#43; Development</td>
      <td data-label=“BRAND&nbsp;YOU"></td>
      <td data-label=“DIGITAL&nbsp;GLAMOUR">&#9733;</td>
      <td data-label=“VIP&nbsp;STATUS">&#9733;</td>
      <td data-label=“ECOMMERCE&nbsp;ELEGANCE">&#9733;</td>   
    </tr>
            <tr>
      <td scope="row">MailChimp Integration</td>
      <td data-label=“BRAND&nbsp;YOU"></td>
      <td data-label=“DIGITAL&nbsp;GLAMOUR">&#9733;</td>
      <td data-label=“VIP&nbsp;STATUS">&#9733;</td>
      <td data-label=“ECOMMERCE&nbsp;ELEGANCE">&#9733;</td>         
    </tr>
                <tr>
      <td scope="row">Email Marketing Automation</td>
      <td data-label=“BRAND&nbsp;YOU"></td>
      <td data-label=“DIGITAL&nbsp;GLAMOUR">&#9733;</td>
      <td data-label=“VIP&nbsp;STATUS">&#9733;</td>
      <td data-label=“ECOMMERCE&nbsp;ELEGANCE">&#9733;</td>         
    </tr>
                    <tr>
      <td scope="row">Ecommerce Enabled</td>
      <td data-label=“BRAND&nbsp;YOU"></td>
      <td data-label=“DIGITAL&nbsp;GLAMOUR">&#9733;</td>
      <td data-label=“VIP&nbsp;STATUS">&#9733;</td>
      <td data-label=“ECOMMERCE&nbsp;ELEGANCE">&#9733;</td>        
    </tr>
                        <tr>
      <td scope="row">Stripe Payment Integration</td>
      <td data-label=“BRAND&nbsp;YOU"></td>
      <td data-label=“DIGITAL&nbsp;GLAMOUR">&#9733;</td>
      <td data-label=“VIP&nbsp;STATUS">&#9733;</td>
      <td data-label=“ECOMMERCE&nbsp;ELEGANCE">&#9733;</td>         
    </tr>
                            <tr>
      <td scope="row">Private Membership Portal</td>
      <td data-label=“BRAND&nbsp;YOU"></td>
      <td data-label=“DIGITAL&nbsp;GLAMOUR"></td>
      <td data-label=“VIP&nbsp;STATUS">&#9733;</td>
      <td data-label=“ECOMMERCE&nbsp;ELEGANCE"></td>        
    </tr>
                                <tr>
      <td scope="row">Tiered Subscription Plans</td>
      <td data-label=“BRAND&nbsp;YOU"></td>
      <td data-label=“DIGITAL&nbsp;GLAMOUR"></td>
      <td data-label=“VIP&nbsp;STATUS">&#9733;</td>
      <td data-label=“ECOMMERCE&nbsp;ELEGANCE"></td>        
    </tr>
                                    <tr>
      <td scope="row">Complete Ecommerce Development</td>
      <td data-label=“BRAND&nbsp;YOU"></td>
      <td data-label=“DIGITAL&nbsp;GLAMOUR"></td>
      <td data-label=“VIP&nbsp;STATUS"></td>
      <td data-label=“ECOMMERCE&nbsp;ELEGANCE">&#9733;</td>        
    </tr>
      <tr>
      <td scope="row">Customer Management Panel</td>
      <td data-label=“BRAND&nbsp;YOU"></td>
      <td data-label=“DIGITAL&nbsp;GLAMOUR"></td>
      <td data-label=“VIP&nbsp;STATUS">&#9733;</td>
      <td data-label=“ECOMMERCE&nbsp;ELEGANCE">&#9733;</td>        
    </tr>
                                            <tr>
      <td scope="row">Traffic Analytics Panel</td>
      <td data-label=“BRAND&nbsp;YOU"></td>
      <td data-label=“DIGITAL&nbsp;GLAMOUR">&#9733;</td>
      <td data-label=“VIP&nbsp;STATUS">&#9733;</td>
      <td data-label=“ECOMMERCE&nbsp;ELEGANCE">&#9733;</td>        
    </tr>
                                                <tr>
      <td scope="row">Site Management Training</td>
      <td data-label=“BRAND&nbsp;YOU"></td>
      <td data-label=“DIGITAL&nbsp;GLAMOUR">&#9733;</td>
      <td data-label=“VIP&nbsp;STATUS">&#9733;</td>
      <td data-label=“ECOMMERCE&nbsp;ELEGANCE">&#9733;</td>        
    </tr>
     <tr>
      <td scope="row">SEO Optimization</td>
      <td data-label=“BRAND&nbsp;YOU"></td>
      <td data-label=“DIGITAL&nbsp;GLAMOUR">&#9733;</td>
      <td data-label=“VIP&nbsp;STATUS">&#9733;</td>
      <td data-label=“ECOMMERCE&nbsp;ELEGANCE">&#9733;</td>        
    </tr>
  </tbody>
</table>

Thank you so much!

2

Answers


  1. try this:

    your height in mobile view are depend on the <td></td>, and some td does not have that star cause the height problem. Simple fix will be add height: 1.45em; to table td

    https://jsfiddle.net/dalinhuang/9j48wcky/1/

      table td {
        border-bottom: 1px solid #ddd;
        display: block;
        font-size: .8em;
        text-align: left;
        height: 1.45em;
      }
    
    Login or Signup to reply.
  2. Your table is looking really cool, and the easiest fix I can think of is to change the max width from 600px to 100% in @media screen

    @media screen and (max-width: 600px) //your code (Remove it and replace by modified code)
    
    
    @media screen and (max-width: 100%) //modified code
    

    It will work like a charm.
    Hope it helps…

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search