簡體   English   中英

Bootstrap響應表滾動條頂部/底部並始終可見

[英]Bootstrap Responsive Table Scrollbar Top/Bottom & Always Visible

我使用“表響應”類在bootstrap中開發了一個表,它按預期工作,但由於表格相當大,並且將在一系列設備上使用,我需要使其更加用戶友好。 我搜索了論壇,但找不到我想要的東西。

是否可以讓響應表底部出現的滾動條始終可見,而不僅僅是在屏幕最小化到一定程度時?

還有什么方法可以復制表頂部的滾動條嗎? 由於表格很長,因此在頂部和底部可以看到它是一個更好的解決方案。

對於頂部的水平滾動條,請嘗試使用jquery.doubleScroll 插件

jQuery的:

$(document).ready(function(){
  $('.table-responsive').doubleScroll();
});

如果我找對你 使表所在的容器具有固定的高度,並將溢出屬性設置為auto。 通過這樣做,你的表不能100%,因為它將填充其容器。 這意味着該表具有固定寬度,也比它的容器大,以顯示溢出效果。 見下面的示例。 我希望它有助於或指向正確的方向

 .table-cont { max-width: 400px; max-height: 200px; overflow: auto; border: 1px red solid; } .table-cont .table { min-width: 600px; } 
 <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <div class="table-cont"> <table class="table"> <thead> <tr> <th>Firstname</th> <th>Lastname</th> <th>Email</th> </tr> </thead> <tbody> <tr> <td>Default</td> <td>Defaultson</td> <td>def@somemail.com</td> </tr> <tr class="success"> <td>Success</td> <td>Doe</td> <td>john@example.com</td> </tr> <tr class="danger"> <td>Danger</td> <td>Moe</td> <td>mary@example.com</td> </tr> <tr class="info"> <td>Info</td> <td>Dooley</td> <td>july@example.com</td> </tr> <tr class="warning"> <td>Warning</td> <td>Refs</td> <td>bo@example.com</td> </tr> <tr class="active"> <td>Active</td> <td>Activeson</td> <td>act@example.com</td> </tr> </tbody> </table> </div> </div> </body> </html> 

你走了

<div class="table-responsive">
 <table class=""table table-striped table-bordered">
  <!--Rest of the code-->

 </table>


 </div>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM