Skip to content

Instantly share code, notes, and snippets.

@AllThingsSmitty
Created April 10, 2015 20:06
Show Gist options
  • Save AllThingsSmitty/cb32e5a377716bc8f147 to your computer and use it in GitHub Desktop.
Save AllThingsSmitty/cb32e5a377716bc8f147 to your computer and use it in GitHub Desktop.
Simple responsive table in CSS (no JS)
<table>
<thead>
<tr>
<th>Payment</th>
<th>Issue Date</th>
<th>Amount</th>
<th>Period</th>
</tr>
</thead>
<tbody>
<tr>
<td data-label="Payment">Payment #1</td>
<td data-label="Issue Date">02/01/2015</td>
<td data-label="Amount">$2,311</td>
<td data-label="Period">01/01/2015 - 01/31/2015</td>
</tr>
<tr>
<td data-label="Payment">Payment #2</td>
<td data-label="Issue Date">03/01/2015</td>
<td data-label="Amount">$3,211</td>
<td data-label="Period">02/01/2015 - 02/28/2015</td>
</tr>
</tbody>
</table>
@import url(http://fonts.googleapis.com/css?family=Open+Sans);
body {
font-family: "Open Sans", sans-serif;
}
table {
border: 1px solid #ccc;
border-collapse: collapse;
margin:0;
padding:0;
width: 100%;
}
table tr {
border: 1px solid #ddd;
padding: 5px;
}
table th, table td {
padding: 10px;
text-align: center;
}
table th {
font-size: 14px;
letter-spacing: 1px;
text-transform: uppercase;
}
@media screen and (max-width: 600px) {
table {
border: 0;
}
table thead {
display: none;
}
table tr {
border-bottom: 2px solid #ddd;
display: block;
margin-bottom: 10px;
}
table td {
border-bottom: 1px dotted #ccc;
display: block;
font-size: 13px;
text-align: right;
}
table td:last-child {
border-bottom: 0;
}
table td:before {
content: attr(data-label);
float: left;
font-weight: bold;
text-transform: uppercase;
}
}
@theumar98
Copy link

good work

@anhtata
Copy link

anhtata commented Oct 11, 2019

work well! thanks!

@militiwari
Copy link

Thank you very much. It is very nice.

@kabilashgit
Copy link

Nice efforts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment