Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.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 表格标题colspan和rowspan固定位置可滚动_Html_Css - Fatal编程技术网

Html 表格标题colspan和rowspan固定位置可滚动

Html 表格标题colspan和rowspan固定位置可滚动,html,css,Html,Css,“测线(n)”标头不像“传感器(n)”标头那样固定。 如何解决这个问题 .table-scroll { position: relative; width:100%; z-index: 1; margin: auto; overflow: scroll; height: 55vh; } .table-scroll table { width: 100%; min-width: 100px; margin: auto;

“测线(n)”标头不像“传感器(n)”标头那样固定。 如何解决这个问题

.table-scroll {
    position: relative;
    width:100%;
    z-index: 1;
    margin: auto;
    overflow: scroll;
    height: 55vh;
}
.table-scroll table {
    width: 100%;
    min-width: 100px;
    margin: auto;
    border-collapse: separate;
    border-spacing: 0;
}
.table-wrap {
    position: relative;
}
.table-scroll th,
.table-scroll td {
    padding: 5px 10px;
    border: 1px solid #000;
    #background: #fff;
    vertical-align: top;
    text-align: center;
}
.table-scroll thead th {
    background: #333;
    color: #fff;
    position: -webkit-sticky;
    position: sticky;
    top: 0;
}
th.sticky {
    position: -webkit-sticky;
    position: sticky;
    left: 0;
    z-index: 2;
    background: #ccc;
}
thead th.sticky {
    z-index: 5;
}
当我左右滚动“LINE(n)”标题时,工作正常, 但当我上下滚动时,“LINE(n)”标题将移动。如何解决这个问题

.table-scroll {
    position: relative;
    width:100%;
    z-index: 1;
    margin: auto;
    overflow: scroll;
    height: 55vh;
}
.table-scroll table {
    width: 100%;
    min-width: 100px;
    margin: auto;
    border-collapse: separate;
    border-spacing: 0;
}
.table-wrap {
    position: relative;
}
.table-scroll th,
.table-scroll td {
    padding: 5px 10px;
    border: 1px solid #000;
    #background: #fff;
    vertical-align: top;
    text-align: center;
}
.table-scroll thead th {
    background: #333;
    color: #fff;
    position: -webkit-sticky;
    position: sticky;
    top: 0;
}
th.sticky {
    position: -webkit-sticky;
    position: sticky;
    left: 0;
    z-index: 2;
    background: #ccc;
}
thead th.sticky {
    z-index: 5;
}

您需要根据
行添加
tr th
的顶部位置,否则第一行和第二行会覆盖上面的一行,添加下面的
css

.table-scroll thead tr:nth-child(2) th {
    top: 30px;
}

谢谢你,海伦。面对这个问题好几天了。