Created
October 23, 2019 17:58
-
-
Save johnborges/f3ebb83db69d7473554a473c899db788 to your computer and use it in GitHub Desktop.
Responsive HTML Tables
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
/* Default span styling - hidden on desktop */ | |
table td span { | |
background: #eee; | |
color: dimgrey; | |
display: none; | |
font-size: 10px; | |
font-weight: bold; | |
padding: 5px; | |
position: absolute; | |
text-transform: uppercase; | |
top: 0; | |
left: 0; | |
} | |
/* Simple CSS for flexbox table on mobile */ | |
@media(max-width: 800px) { | |
table thead { | |
left: -9999px; | |
position: absolute; | |
visibility: hidden; | |
} | |
table tr { | |
border-bottom: 0; | |
display: flex; | |
flex-direction: row; | |
flex-wrap: wrap; | |
margin-bottom: 40px; | |
} | |
table td { | |
border: 1px solid; | |
margin: 0 -1px -1px 0; | |
padding-top: 35px; /* additional padding to avoid heading overlap */ | |
position: relative; | |
width: 50%; | |
} | |
/* Show the heading span */ | |
table td span { | |
display: block; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment