我缺少一个技巧吗?我希望桌子也限制在.panel-body的高度。
html, body {
height: 100%;
}
.panel-body {
height: 100px;
}
table {
width: 100%;
height: 100%;
overflow-y: scroll;
}
答案 0 :(得分:2)
您需要将overflow: auto
添加到.panel-body
类,如下所示:
html,
body {
height: 100%;
}
.panel-body {
height: 100px;
overflow: auto;
}
table {
width: 100%;
}
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Panel title</h3>
</div>
<div class="panel-body">
<table>
<thead>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
</thead>
<tbody>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</tbody>
</table>
</div>
</div>
JSFiddle:http://jsfiddle.net/awu1tzoj/2/