gpt4 book ai didi

javascript - html 表格水平滚动启用特定列

转载 作者:行者123 更新时间:2023-11-28 19:16:33 26 4
gpt4 key购买 nike

让我们考虑下图。我正在生成员工工作时间的月度报告。当水平滚动条向右移动时,我希望 code,name, area, territory 列固定在其位置和日期上列应该可以水平滚动。向右滚动时,日期列应位于 code,name, area, territory 列组下方。我该怎么做?是否有任何 css 技巧或插件可用?

Example Table

最佳答案

我认为根据@Circuit Breaker answer 修复列的​​最简单和合乎逻辑的方法是

.view {
margin: auto;
width: 600px;
}

.wrapper {
position: relative;
overflow: auto;
border: 1px solid black;
white-space: nowrap;
}

.sticky-col {
position: sticky;
position: -webkit-sticky;
background-color: white;
}

.first-col {
width: 100px;
min-width: 100px;
max-width: 100px;
left: 0px;
}

.second-col {
width: 150px;
min-width: 150px;
max-width: 150px;
left: 100px;
}
<div class="view">
<div class="wrapper">
<table class="table">
<thead>
<tr>
<th class="sticky-col first-col">Number</th>
<th class="sticky-col second-col">First Name</th>
<th>Last Name</th>
<th>Employer</th>
</tr>
</thead>
<tbody>
<tr>
<td class="sticky-col first-col">1</td>
<td class="sticky-col second-col">Mark</td>
<td>Ham</td>
<td>Micro</td>
</tr>
<tr>
<td class="sticky-col first-col">2</td>
<td class="sticky-col second-col">Jacob</td>
<td>Smith</td>
<td>Adob Adob Adob AdobAdob Adob Adob Adob Adob</td>
</tr>
<tr>
<td class="sticky-col first-col">3</td>
<td class="sticky-col second-col">Larry</td>
<td>Wen</td>
<td>Goog Goog Goog GoogGoog Goog Goog Goog Goog Goog</td>
</tr>
</tbody>
</table>
</div>
</div>

关于javascript - html 表格水平滚动启用特定列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58163631/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com