編輯:我試過在本主題中推薦的解決方案,此帖可能是重複的。從jsfiddle.net/DJqPf/7/複製並粘貼解決方案到john.nichel.net/test2.html(我沒有足夠的代表發佈兩個鏈接,所以我不能給你的http),它不'完全不滾動。使用CSS鎖定列
我正在尋找使用CSS鎖定表或div中的一列或兩列數據,這意味着其他列滾動但鎖定的不是。
我已經嘗試了幾個jQuery插件和我發現的許多CSS/div示例,但無論出於何種原因,我都無法使解鎖的列在鎖定的列後啓動。我試過絕對,固定,相對等位置,但似乎無法讓這些例子工作。我怎樣才能做到這一點?
下面的代碼也在http://john.nichel.net/test.html,因此您可以看到鎖定列如何顯示在其他列上。我將繼續努力,因此我網站上的代碼可能與我在下面發佈的代碼不同。
.table {
display: table;
}
.header {
display: table-header-group;
font-weight: bold;
}
.rowGroup {
display: table-row-group;
}
.row {
display: table-row;
}
.cell {
display: table-cell;
white-space: nowrap;
}
.cell_locked {
position: absolute;
display: table-cell;
white-space: nowrap;
}
<center>
<div style="overflow-x:auto;width:770px;overflow:scroll;">
<div class="table">
<div class="header">
<div class="cell_locked">Test Lock</div>
<div class="cell">Unlocked Cell 1</div>
<div class="cell">Unlocked Cell 2</div>
<div class="cell">Unlocked Cell 3</div>
<div class="cell">Unlocked Cell 4</div>
<div class="cell">Unlocked Cell 5</div>
<div class="cell">Unlocked Cell 6</div>
<div class="cell">Unlocked Cell 7</div>
<div class="cell">Unlocked Cell 8</div>
<div class="cell">Unlocked Cell 9</div>
<div class="cell">Unlocked Cell 10</div>
</div>
</div>
</center>
什麼是「鎖一列」的位置呢?像Excel電子表格一樣凍結其他列滾動但凍結列不行? –
是的,這就是我想要做的。 – omgwtfbbq
[在水平滾動中修復列]可能的副本(https://stackoverflow.com/questions/18826775/fix-columns-in-horizontal-scrolling) – dbrree