html - 如何向表格添加水平滚动
问题描述
我有一个表格,其中有固定的标题和垂直滚动tbody
。但是,此表中的列可能会显着增长,我想添加水平滚动。在超过 3 列的那一刻,表格看起来不正确。
具有三列的 JS Fiddle(它的外观):https ://jsfiddle.net/maxshuty/DTcHh/42626/
JS Fiddle 四列(这应该看起来像三列小提琴):https ://jsfiddle.net/DTcHh/67311/
我相信有问题的课程是header-fixed
. 它具有以下内容:
.header-fixed > tbody > tr:after,
.header-fixed > thead > tr:after {
content: ' ';
display: block;
visibility: hidden;
clear: both;
}
这阻止了行被溢出。
解决方案
请查看以下链接:
我删除了浮动并添加了 flexbox,并添加了#Row1 样式以实现溢出。我希望这有帮助。
.header-fixed > thead > tr > th {
width: auto;
min-width: 20%;
float: left;
display: flex;
}
#Row1 {
overflow-x: scroll;
width: auto;
display: inline-flex;
}
推荐阅读
- vim - 如果通过资源管理器地址栏打开'vim',则在 cmd 中无法识别?
- python - Facebook 的 Python Business SDK 使用了一个保留关键字——解决方法?
- python - 仅显示来自一个集群的数据
- jquery - 在元素上添加一个 JQuery 类,加载时没有过渡
- c - C语言中函数指针在数据结构开发中的使用
- unity3d - 为什么我不能像这样使用统一的 audioMixer?
- javascript - if 语句返回 true,但条件不会触发
- haskell - 在带有 Servant 的内部 Api 之前添加公共根路径
- excel - VBA损坏的复制粘贴循环
- powershell - 如何使用 Powershell 在 ActiveDirectory 中设置登录时间以拒绝登录