【发布时间】:2017-02-22 23:21:33
【问题描述】:
我正在使用 bootstrap 3 使我的网站具有响应性,并且我有一个带有“表格响应”的 div 的表格。我想要一个允许我在屏幕很小时垂直滚动的表格,但它也需要水平滚动,因为它们在表格中有超过 50 个项目。如何使表格可滚动且响应迅速?
我正在尝试这个 css,但表格会增长并且没有水平滚动......
application.css.scss
//table becomes responsive with scrollbar
.table-responsive {
width: 100%;
height: 200px !important;
overflow: auto;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: -ms-autohiding-scrollbar;
border: 1px solid #DDD;
}
上面的css可以工作,但是头部需要固定在滚动体上方。
html
<div class= "container">
<div class="table-responsive">
<table class="table table-colored table-hover table-bordered">
<thead>
<tr>
<th width="20%">Applicant's Name</th>
<th width="20%">Applicant's Email</th>
<th width="20%">Date Requested </th>
<th width="40%">Report View/Download</th>
</tr>
</thead>
<tbody>
<% current_manager.reportapprovals.each do |ra| %>
<% if ra.report.present? %>
<tr>
<td width="20%"><%= ra.tenant_last_name.truncate(17) %></td>
<td width="20%"><%= ra.tenant_email.truncate(17) %></td>
<td width="20%"><%= ra.date_approved %></td>
</tr>
<% end %>
<% end %>
</div>
<% end %>
</tbody>
</div>
</table>
【问题讨论】:
-
请同时发布您的 HTML 代码。
-
试试这个链接jsfiddle.net/ho9mo49r/1
标签: html css twitter-bootstrap