Currently, I am working with media queries that target specific devices to adjust the display of tables. By using the code provided below, I can modify the table structure based on screen size and device specifications:
@media
only screen and (max-width: 760px),
(min-device-width: 768px) and (max-device-width: 1024px) {
/* Changing the table layout */
table, thead, tbody, th, td, tr {
display: block;
}
/* Hiding the table headers for accessibility */
thead tr {
position: absolute;
top: -9999px;
left: -9999px;
}
tr { border: 1px solid #ccc; }
td {
border: none;
border-bottom: 1px solid #eee;
position: relative;
padding-left: 50%;
}
td:before {
position: absolute;
top: 6px;
left: 6px;
width: 45%;
padding-right: 10px;
white-space: nowrap;
}
}
The challenge now is applying this media query selectively to a specific table rather than all table
elements. Any suggestions on how I can achieve this?