2014-05-02 39 views
0

我有一個div內部的HTML表格,這裏是截圖 enter image description hereHTML表的colums滾動

表處於<div></div>現在有overflow xy:auto 但這種方式滾動整個表 我想要做的是修復Sheet1列,並允許其他列滾動我怎麼能做到這一點?

以下是這撥弄我要讓Fields列固定和Records列水平滾動演示的jsfiddle http://jsfiddle.net/8aaZZ/ ..

+1

如果您可以在jsfiddle.net或類似網站中重現問題,會更容易提供幫助。 – Arbel

+0

請發佈您的標記和CSS,並考慮放在一起復制問題的jsFiddle。 – BenM

+0

好吧,可能是地獄的混亂因爲這張桌子正在通過mvc填充,但我會盡量根據這個場景製作一個js小提琴。 –

回答

1

給予position:absolute過第一欄就可以達到的效果。

這是一個DEMO

.table-data 
{ 
    background:#f6f6f6; 
    overflow-x:scroll; 
    overflow-y:visible; 
    margin-left:5em; 
    width: 60%; 
} 

table{border-collapse:separate; table-layout:fixed;} 

table th td{padding:5px; width:100px;} 
table td{border:1px solid gray;} 

table td:not(:first-child) 
{background:#f6f6f6;overflow-x:scroll; } 

table td:not(:first-child):hover 
{background:red;overflow-x:scroll;} 

table td:first-child, table th:first-child{ 
    position:absolute; 
    width:5em; 
    left:0; 
    top:auto; 
    background:cyan; 
} 
+0

謝謝,這正是我一直在尋找的內容: ) –