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
.
.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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.