如何冻结顶部<;th>;和左<;th>;同时创建一个HTML表
我有下面的长表(从数据库动态生成)显示在整个页面中。由于表格的长度,它有垂直和水平滚动条 我能够用以下如何冻结顶部<;th>;和左<;th>;同时创建一个HTML表,html,css,html-table,Html,Css,Html Table,我有下面的长表(从数据库动态生成)显示在整个页面中。由于表格的长度,它有垂直和水平滚动条 我能够用以下CSScode将标题固定在固定位置 表格{ 边界间距:0; 宽度:100%; 溢出y:自动; 高度:50vh; } thead th{ 位置:粘性; 排名:0; 背景色:白色; }您可以使用两个表,一个用于左列,另一个用于其余列以实现此效果 演示: .tbls续{ 显示:块; 背景颜色:绿色; 溢出:自动; 宽度:100%; } .lft{ 位置:固定; 背景色:红色; 右边距:5px;
CSS
code将标题固定在固定位置
表格{
边界间距:0;
宽度:100%;
溢出y:自动;
高度:50vh;
}
thead th{
位置:粘性;
排名:0;
背景色:白色;
}
您可以使用两个表,一个用于左列,另一个用于其余列以实现此效果
演示:
.tbls续{
显示:块;
背景颜色:绿色;
溢出:自动;
宽度:100%;
}
.lft{
位置:固定;
背景色:红色;
右边距:5px;
宽度:10%;
}
.rgt{
宽度:90%;
浮动:对;
}
#
弗斯特
1.
做记号
2.
雅各布
最后
手柄
手柄
手柄
手柄
手柄
手柄
手柄
手柄
手柄
手柄
手柄
手柄
手柄
手柄
奥托
@mdo
@mdo
@mdo
@mdo
@mdo
@mdo
@mdo
@mdo
@mdo
@mdo
@mdo
@mdo
@mdo
@mdo
桑顿
@肥
@肥
@肥
@肥
@肥
@肥
@肥
@肥
@肥
@肥
@肥
@肥
@肥
@肥
编辑:我认为您需要一个外部库,请检查:github.com/yidas/jquery-freeze-table,我认为它将解决您的问题。您可以使用两个表,一个用于左列,另一个用于其余列 演示:
.tbls续{
显示:块;
背景颜色:绿色;
溢出:自动;
宽度:100%;
}
.lft{
位置:固定;
背景色:红色;
右边距:5px;
宽度:10%;
}
.rgt{
宽度:90%;
浮动:对;
}
#
弗斯特
1.
做记号
2.
雅各布
最后
手柄
手柄
手柄
手柄
手柄
手柄
手柄
手柄
手柄
手柄
手柄
手柄
手柄
手柄
奥托
@mdo
@mdo
@mdo
@mdo
@mdo
@mdo
@mdo
@mdo
@mdo
@mdo
@mdo
@mdo
@mdo
@mdo
桑顿
@肥
@肥
@肥
@肥
@肥
@肥
@肥
@肥
@肥
@肥
@肥
@肥
@肥
@肥
编辑:我想你需要一个外部库,检查一下:github.com/yidas/jquery-freeze-table,我想它会的
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
.tbls-cont{
display:block;
background-color:green;
overflow:auto;
width:100%;
}
.lft{
position:fixed;
background-color:red;
margin-right:5px;
width:10%;
}
.rgt{
width:90%;
float:right;
}
</style>
</head>
<body>
<div class='tbls-cont' id='main_cont'>
<div class='lft' id='sub-cont-lft'>
<table class="table table-hover static" id='left_tbl'>
<thead>
<tr>
<th scope="col">#
</th>
<th scope="col">First
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1
</th>
<td>Mark
</td>
</tr>
<tr>
<th scope="row">2
</th>
<td>Jacob
</td>
</tr>
</tbody>
</table>
</div>
<div class='rgt' id='sub-cont-rgt'>
<table class="table table-hover" id='right_tbl'>
<thead>
<tr>
<th scope="col">Last
</th>
<th scope="col">Handle
</th>
<th scope="col">Handle
</th>
<th scope="col">Handle
</th>
<th scope="col">Handle
</th>
<th scope="col">Handle
</th>
<th scope="col">Handle
</th>
<th scope="col">Handle
</th>
<th scope="col">Handle
</th>
<th scope="col">Handle
</th>
<th scope="col">Handle
</th>
<th scope="col">Handle
</th>
<th scope="col">Handle
</th>
<th scope="col">Handle
</th>
<th scope="col">Handle
</th>
</tr>
</thead>
<tbody>
<tr>
<td>Otto
</td>
<td>@mdo
</td>
<td>@mdo
</td>
<td>@mdo
</td>
<td>@mdo
</td>
<td>@mdo
</td>
<td>@mdo
</td>
<td>@mdo
</td>
<td>@mdo
</td>
<td>@mdo
</td>
<td>@mdo
</td>
<td>@mdo
</td>
<td>@mdo
</td>
<td>@mdo
</td>
<td>@mdo
</td>
</tr>
<tr>
<td>Thornton
</td>
<td>@fat
</td>
<td>@fat
</td>
<td>@fat
</td>
<td>@fat
</td>
<td>@fat
</td>
<td>@fat
</td>
<td>@fat
</td>
<td>@fat
</td>
<td>@fat
</td>
<td>@fat
</td>
<td>@fat
</td>
<td>@fat
</td>
<td>@fat
</td>
<td>@fat
</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>