I have a table where the amount of items listed in TBODY
is quite large and I would like to add a scroll by setting the maximum size of TBODY
to 500px.
I tried to do this but it did not work (I'm using Google Chrome)
#scroll{
max-height: 100px;
overflow: auto;
}
<table>
<tbody id="scroll">
<tr>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
</tr>
<tr>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
</tr>
<tr>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
</tr>
<tr>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
</tr>
<tr>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
</tr>
<tr>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
</tr>
<tr>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
</tr>
<tr>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
</tr>
<tr>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
<td>Valor</td>
</tr>
</tbody>
</table>
But doing something like DIV
works perfectly:
#scroll{
max-height: 100px;
overflow: auto;
}
<div id="scroll">
<div>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
</div>
<div>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
</div>
<div>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
</div>
<div>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
</div>
<div>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
</div>
<div>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
</div>
<div>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
</div>
<div>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
</div>
<div>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
<span>Valor</span>
</div>
</div>
How can I set a overflow
with scroll within a TBODY
?