【发布时间】:2021-12-25 07:09:36
【问题描述】:
我正在尝试使用 bootstrap 3 表制作具有固定标题和可滚动内容的表。 不幸的是,我找到的解决方案不适用于 bootstrap 或破坏样式。
这里有一个简单的引导表,但由于某种原因,我不知道 tbody 的高度不是 10px。
height: 10px !important; overflow: scroll;
例子:
<link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
<table class="table table-striped">
<thead>
<tr>
<th>Make</th>
<th>Model</th>
<th>Color</th>
<th>Year</th>
</tr>
</thead>
<tbody style="height: 10px !important; overflow: scroll; ">
<tr>
<td class="filterable-cell">111 Ford</td>
<td class="filterable-cell">Escort</td>
<td class="filterable-cell">Blue</td>
<td class="filterable-cell">2000</td>
</tr>
<tr>
<td class="filterable-cell">Ford</td>
<td class="filterable-cell">Escort</td>
<td class="filterable-cell">Blue</td>
<td class="filterable-cell">2000</td>
</tr>
<tr>
<td class="filterable-cell">Ford</td>
<td class="filterable-cell">Escort</td>
<td class="filterable-cell">Blue</td>
<td class="filterable-cell">2000</td>
</tr>
<tr>
<td class="filterable-cell">Ford</td>
<td class="filterable-cell">Escort</td>
<td class="filterable-cell">Blue</td>
<td class="filterable-cell">2000</td>
</tr>
</tbody>
</table>
【问题讨论】:
-
这绝对帮助了我。这里的解决方案jsfiddle.net/T9Bhm/7谢谢
-
当 td 高度不匹配时,无法正确处理 table-striped 属性。 jsfiddle.net/T9Bhm/4755 见添加的 td { overflow-wrap: break-word;我添加的}
-
我认为更好和更旧的 SO 线程被标记为重复:p stackoverflow.com/questions/17067294/…
标签: html css twitter-bootstrap html-table