I have a table that needs to be optimized for mobile screens.
https://i.sstatic.net/61GPr.png
The goal is to rearrange the columns on mobile screens to save space, like in the example below:
https://i.sstatic.net/ojo2N.png
What's the best way to achieve this?
Here is the current code snippet:
table {
border-collapse: collapse;
width: 100%;
}
th, td {
padding: 12px;
text-align: left;
border-bottom: 1px solid #ddd;
}
...
<section class="table-responsive">
<table id="myTable" class="table table-sm">
<thead>
<tr>
<th></th>
<th></th>
<th>
...
</th>
...
</tr>
</thead>
<tbody>
...
</tbody>
</table>
</section>
Any suggestions on how to achieve the desired layout on mobile?