html - 如何在底部显示滚动条并将表格高度设为自动?
问题描述
我已经编写了以下 css,它在我的笔记本电脑上按预期工作。但是当使用更大的显示器时,我会在表格末尾看到空白区域。
.wrapper{
width:auto;
height: 500px;
overflow-x: scroll;
overflow-y: scroll;
}
当我使用overflow :auto;
垂直滚动条被完全删除并看到水平滚动条时,我必须一直向下滚动
html
如下:
<div class="wrapper">
<table id="myTable" datatable="ng" [dtOptions]="dtOptions" [dtTrigger]="dtTrigger" dt-instance="dtInstance" class="table table-striped table-bordered display nowrap
table-sm row-border hover" width="100%">
<thead>
<tr>
<th style="min-width: 120px">hostName</th>
...
</tr>
</thead>
<tbody>
<tr style="text-align: left; word-break: break-all;">
<td>value</td>
...
</tr>
</tbody>
</table>
</div>
如果我这样做height: auto
,则水平滚动条位于最底部,并且不会显示在页面顶部,并且垂直滚动条不再可滚动。
解决方案
尝试在您的body
和html
标签中提供 100% 的高度:
html, body {
height: 100%;
margin: 0px;
padding: 0px;
}
.wrapper{
width: 100%;
height: 100%;
overflow-x: scroll;
overflow-y: scroll;
}
推荐阅读
- scala - 向码头添加自定义处理程序会引发 ClassNotFoundException
- http - 1 秒后未订阅 Akka HTTP 错误响应实体
- java - Spring Security:我如何让@WithMockUser 返回一个类型对象 User.class
- spring - SpringBoot OAuth2 自定义登录页面
- python-3.x - 使用变量更新 sqlite3 表的一部分
- c# - 对控制器的 Ajax 调用正在发送数据,但如果是 if 语句,我将无法使用它
- javascript - 将具有 A 类的项目分组,其前面是具有 B 类的元素
- google-apps-script - 查询 2 组表格数据并找出差异
- python - 在python中进行网络抓取时删除具有相同类引用的图像源?
- python - 如何删除运行 VisualStudio 的 Anaconda 环境?