Created
July 15, 2019 17:31
-
-
Save rodrigobertin/caf87456b713d710d0c7184e43d6c361 to your computer and use it in GitHub Desktop.
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').each(function () { | |
let This = $(this); | |
let lista = []; | |
This.find('th').each(function (index) { | |
console.log(index); | |
let Th = $(this); | |
let text = Th.text(); | |
lista.push(text); | |
}); | |
This.find('tr').each(function () { | |
$(this).find('td').each(function (index) { | |
$(this).attr('data-label', lista[index]); | |
}); | |
}); | |
}); |
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
@media screen and (max-width: 600px) { | |
table caption { | |
font-size: 1.5em; | |
margin: .5em 0 .75em; | |
} | |
table tr { | |
background-color: #f8f8f8; | |
border: 1px solid #ddd; | |
padding: .39em; | |
} | |
table th, | |
table td { | |
padding: .625em; | |
text-align: center; | |
} | |
table th { | |
font-size: .85em; | |
letter-spacing: .1em; | |
text-transform: uppercase; | |
} | |
table { | |
border: 0; | |
caption { | |
font-size: 1.3em; | |
} | |
thead { | |
border: none; | |
clip: rect(0 0 0 0); | |
height: 1px; | |
margin: -1px; | |
overflow: hidden; | |
padding: 0; | |
position: absolute; | |
width: 1px; | |
} | |
tr { | |
border-bottom: 3px solid #ddd; | |
display: block; | |
margin-bottom: .625em; | |
} | |
td { | |
border-bottom: 1px solid #ddd; | |
display: block; | |
font-size: .8em; | |
text-align: right; | |
} | |
td::before { | |
/* | |
* aria-label has no advantage, it won't be read inside a table | |
content: attr(aria-label); | |
*/ | |
content: attr(data-label); | |
float: left; | |
font-weight: bold; | |
text-transform: uppercase; | |
} | |
} | |
table td:last-child { | |
border-bottom: 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment