JSFiddle - React, Tailwind, and code Playground
by David Thomas
HTML
<table>
<colgroup>
<col class="foods" />
<col class="calories" />
</colgroup>
<thead>
<tr>
<th>Food</th>
<th>Calories</th>
</tr>
</thead>
<tbody>
<tr class="header">
<td colspan="2">Fruits</td>
</tr>
<tr>
<td>Apple</td>
<td>90</td>
</tr>
<tr>
<td>Grape</td>
<td>5</td>
</tr>
<tr>
<td>Strawberry</td>
<td>16</td>
</tr>
</tbody>
<tbody>
<tr class="header">
<td colspan="2">Vegetable</td>
</tr>
<tr>
<td>Cucumber</td>
<td>12</td>
</tr>
<tr>
<td>Onion</td>
<td>29</td>
</tr>
</tbody>
</table>
CSS
.foods,
.calories {
width: 8em;
}
tbody tr.header {
height: 2em;
line-height: 2em;
}
tbody tr,
tbody tr td {
max-height: 0;
line-height: 0;
overflow: hidden;
-moz-transition: all 1s linear;
-ms-transition: all 1s linear;
-o-transition: all 1s linear;
-webkit-transition: all 1s linear;
transition: all 1s linear;
}
tbody tr td:first-child {
padding-left: 2em;
}
tbody tr.header td {
padding: 0;
}
tbody:hover tr {
height: 2em;
max-height: 2em;
line-height: 2em;
-moz-transition: all 1s linear;
-ms-transition: all 1s linear;
-o-transition: all 1s linear;
-webkit-transition: all 1s linear;
transition: all 1s linear;
}