I found this amazing CSS code class for a responsive table. I love it. The problem is that the media query for the mobile screen overrides other table classes I created. I tried to name the table something else, to avoid the problem. I named it ".table-lead-sheets". The first section workd perfectly, there is no override. The second section with the media query overrides the other table classes. Please advise on any suggestions. I have the code below. It is a great asset, if I could only figure out that one bug.
/*
Generic Styling, for Desktops/Laptops
*/
.table-lead-sheets {
width: 60%;
border-collapse: collapse;
font: normal 1.8em;
font-family: Baskerville, "Palatino Linotype", Palatino, "Century Schoolbook L", "Times New Roman", serif;
margin-left: auto;
margin-right: auto;
max-width: 600px;
padding-left: 20px;
}
/* Zebra striping */
tr:nth-of-type(odd) {
background: #eee;
}
th {
background: #333;
color: white;
font-weight: bold;
}
td, th {
padding: 6px;
border: 1px solid #ccc;
text-align: center;
}
@media
only screen and (max-width: 760px)
{
/* Force table to not be like tables anymore */
.table-lead-sheets, thead, tbody, th, td, tr {
display: block;
}
/* Hide table headers (but not display: none;, for accessibility) */
thead tr {
position: absolute;
top: -9999px;
left: -9999px;
}
tr { border: 1px solid #ccc; }
td {
/* Behave like a "row" */
border: none;
border-bottom: 1px solid #eee;
position: relative;
padding-left: 50%;
}
td:before {
/* Now like a table header */
position: absolute;
/* Top/left values mimic padding */
top: 6px;
left: 6px;
width: 45%;
padding-right: 10px;
white-space: nowrap;
}
/*
Label the data
*/
td:nth-of-type(1):before { content: "Model"; }
td:nth-of-type(2):before { content: "Weight"; }
td:nth-of-type(3):before { content: "Size"; }
td:nth-of-type(4):before { content: "Thickness"; }
}