我有一个表在一个模块内的面板内呈现.由于表格相对较大,我想将它的行限制为5,以便模态不会变得可滚动.我浏览了SO和google以及我发现我需要设置overflow-y:auto或overflow-y:滚动以使其工作,但在我的情况下,它没有.我还设置了400px的随机高度和position:absolute.这使得表格可以滚动,但现在面板以< thead>关闭了.并且桌子的主体在面板外面呈现.有什么办法解决这个问题?
我的代码片段是:
<div class="modal fade"> <div class="modal-dialog " > <div class="modal-content"> <div class="modal-body"> <div class="panel panel-default"> <div class="panel-body"> <table class="table table-bordered> <thead> [........] </thead> <tbody style="overflow-y:auto; height:400px; position:absolute> [.......] </tbody> </table>
[…其余的< / div> s …]
编辑
谢谢你的回复.有没有办法将滚动条缩小到< tbody>单独使< thead>保持静止?
解决方法
将其包裹在响应表中并设置最大高度:
.table-responsive { max-height:300px; }