I have the following markup:
<div class="wrapper">
<table>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
<tr><td>1</td></tr>
</table>
</div>
And CSS:
.wrapper {
height: 60px;
}
table {
height: 100%;
overflow: auto;
}
Here is fiddle.
The problem is that table doesn't pick .wrapper's height of 60px. Why?
<table> is by default display: table.
Make it display: block.
Demo
.wrapper {
height: 60px;
}
table {
height: 100%;
overflow: auto;
display: block;
}
<div class="wrapper">
<table>
<tr>
<td>1</td>
</tr>
<tr>
<td>2</td>
</tr>
<tr>
<td>3</td>
</tr>
<tr>
<td>4</td>
</tr>
<tr>
<td>5</td>
</tr>
<tr>
<td>6</td>
</tr>
<tr>
<td>7</td>
</tr>
<tr>
<td>8</td>
</tr>
</table>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With