I have a table with 3 row like below. How can I change the order of row by CSS? Example:
- Name: A B C
- Age: 1 2 3
- Country: US CA CN
And I want it become:
- Country: US CA CN
- Name: A B C
- AGE: 1 2 3
table, th, td {
border: 1px solid black;
}
.value {
text-align: right;
}
td {
padding: 2px 10px;
}
<table class="details">
<tbody>
<tr class="name">
<td class="label"><label for="name">Fullname</label></td>
<td class="value name-wrapper">Ann Smith</td>
<td class="value name-wrapper">Beck Jackson</td>
<td class="value name-wrapper">Chang Winchester</td>
</tr>
<tr class="Age">
<td class="label"><label for="age">Age</label></td>
<td class="value age-wrapper">26</td>
<td class="value age-wrapper">19</td>
<td class="value age-wrapper">54</td>
</tr>
<tr class="Country">
<td class="label"><label for="country">Country</label></td>
<td class="value country-wrapper">CA</td>
<td class="value country-wrapper">US</td>
<td class="value country-wrapper">UK</td>
</tr>
</tbody>
</table>
<tr>
. So I would reformulate: In my opinion, you could create a layout, that simulates a table, with divs and flexbox (or better, withdisplay: grid
). Or use javascript, to switch the order of your table rows. – Sporulate