2017-02-07 23 views
0

我試圖做一個表,一個固定的頭Y軸ONLY就像在Excel)。問題是它需要在X軸上滾動。我發現another answer here但它不適合我。下面是我的測試JSBINHTML表格固定頭文件只能在Y(X中滾動)

style="width: 400px; height: 200px; overflow: scroll;" 

試圖使一個測試用例。並與

position: absolute; 

position: static; 

爲了使頭靜止。另外嘗試與其他問題的答案,對我沒有積極的結果。

這是而不是另一個問題的副本,因爲問題稍有不同。

我可以使用CSS 的Javascript任何來解決這個問題。

回答

0

設置thead s到絕對位置,並修復它裏面的trhttps://jsfiddle.net/yak613/x5stpv9y/

table { 
    position: relative; 
    padding-top: 20px; 
} 
table thead { 
    position: absolute; 
    left: 0; 
    right: 0; 
    top: 0; 
    background: #fff; 
} 
table thead tr { 
    position: fixed; 
    background: #fff; 

} 
+0

不,我是試圖解決同樣的問題:https://jsfiddle.net/x5stpv9y/1/ – driconmax