I'm attempting to apply media queries to a table to hide optional columns on smaller devices.
I have two columns to hide based on two screen breaks:
@media screen and (max-width: 33em) {
th.optional-1,
td.optional-1 {
display: none !important;
}
}
@media screen and (max-width: 43em) {
th.optional-2,
td.optional-2 {
display: none !important;
}
}
Then I apply class="optional-1"
to both the th
and td
elements. I add data-role="table"
to get the table to style correctly.
The media query works fine, however once the table gets to the default responsive size the table drops to a flattened view. I first thought about adding a class to force the table to be unresponsive (which works) but it then stops my optional classes working as both are competing with !important
which is required to get over the default responsive style in JQM.
.table-responsive-none td,
.table-responsive-none th,
.table-responsive-none tbody th,
.table-responsive-none tbody td,
.table-responsive-none thead td,
.table-responsive-none thead th {
display: table-cell !important;
margin: 0 !important;
}
.table-responsive-none td .ui-table-cell-label,
.table-responsive-none th .ui-table-cell-label {
display: none !important;
}
Alternatively I could use data-mode="columntoggle"
but I don't want the behaviour of the column toggling facility and I want to also specify my own breaks.
The problem is fixed when removing data-role="table"
but then the table doesn't look right.