Responsive HTML table that works on an IPAD

Some CSS and Javascript that makes a table be responsive doesn't work right on an IPAD or Iphone.

We know this code works. Just set your table class=responsive.

<table class="responsive">

<!--responsive table code from -->



only screen and (min-width: 760px) {

.item {width:350px;}

.uofm {width:70px;}

.val1 {width:70px;}

.val2 {width:70px;}

.multTotal {width:70px;}


table.responsive {

width: 100%;


border-collapse: collapse;


/* Zebra striping */

.responsive tr:nth-of-type(odd) {

background: #eee;


.responsive th {

background: #333;

color: white;

font-weight: bold;


.responsive td, th {

padding: 6px;

border: 1px solid #ccc;

text-align: left;



Max width before this PARTICULAR table gets nasty

This query will take effect for any screen smaller than 760px

and also iPads specifically.



only screen and (max-width: 760px),

(min-device-width: 768px) and (max-device-width: 1024px) {

/* Force table to not be like tables anymore */

.responsive table, .responsive thead, .responsive tbody, .responsive th, .responsive td, .responsive tr {

display: block;


/* Hide table headers (but not display: none;, for accessibility) */

.responsive thead tr {

position: absolute;

top: -9999px;

left: -9999px;


.responsive tr { border: 1px solid #ccc; }

.responsive td {

/* Behave like a "row" */

border: none;

border-bottom: 1px solid #eee;

position: relative;

padding-left: 30%;


.responsive td:before {

/* Now like a table header */

position: absolute;

/* Top/left values mimic padding */

top: 6px;

left: 6px;

width: 25%;

padding-right: 10px;

white-space: nowrap;



Label the data


.responsive td:nth-of-type(1):before { content: "Item"; }

.responsive td:nth-of-type(2):before { content: "U of M"; }

.responsive td:nth-of-type(3):before { content: "Change UOM"; }

.responsive td:nth-of-type(4):before { content: "Qty"; }

.responsive td:nth-of-type(5):before { content: "Unit Price"; }

.responsive td:nth-of-type(6):before { content: "Total"; }

.responsive td:nth-of-type(7):before { content: "Delete"; }