Created
April 10, 2015 20:06
-
-
Save AllThingsSmitty/cb32e5a377716bc8f147 to your computer and use it in GitHub Desktop.
Simple responsive table in CSS (no JS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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; | |
} | |
} |
work well! thanks!
Thank you very much. It is very nice.
Nice efforts!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
good work