Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何将滚动条添加到具有固定标题行的表中?_Html_Css_Html Table_Scrollbar - Fatal编程技术网

Html 如何将滚动条添加到具有固定标题行的表中?

Html 如何将滚动条添加到具有固定标题行的表中?,html,css,html-table,scrollbar,Html,Css,Html Table,Scrollbar,我的表有太多的列,它溢出了页面的100%宽度。所以我需要在表格中添加一个水平滚动条 但是当有太多的行需要滚动时,我还需要修复垂直滚动条的标题 使用CSS和HTML实现它的正确方法是什么 第一个代码是CSS 表.标题格式{ 文本对齐:居中; 宽度:170px; 字体大小:14px; } 这是HTML代码 A. B C D E 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1.

我的表有太多的列,它溢出了页面的100%宽度。所以我需要在表格中添加一个水平滚动条

但是当有太多的行需要滚动时,我还需要修复垂直滚动条的标题

使用CSS和HTML实现它的正确方法是什么

第一个代码是CSS

表.标题格式{ 文本对齐:居中; 宽度:170px; 字体大小:14px; } 这是HTML代码

A. B C D E 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 您可以在th上使用position:Sticky元素并设置表position:relative,这样就可以完成任务

检查以下内容:

表.标题格式{ 文本对齐:居中; 宽度:170px; 字体大小:14px; } 基本示例{ 位置:相对位置; } 示例基本th{ 职位:-网络工具包粘性; /*狩猎*/ 位置:粘性; 排名:0; z指数:100; 背景:绿色; } A. B C D E 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 检查这个样式 我希望你喜欢

table { text-align: left; position: relative; border-collapse: collapse; } th, td { padding: 0.25rem; } tr th { background: red; color: white; } th { background: white; position: sticky; top: 0; /* Don't forget this, required for the stickiness */ box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.4); }
这就是我需要的。我将稍后在我的项目中尝试。谢谢!对不起,它不是很友好,当我滚动时它会抖动。。。有任何引导方法吗?检查此项您可以设置tbody的高度并滚动到AutoPlace read(自动租赁阅读)-总结是,这不是一种理想的方法来向志愿者讲话,并且可能会对获得答案产生反作用。请不要将此添加到您的问题中。