2014-04-10 19 views
0

在資源管理器中,我可以在使用css表達式滾動時保持表格的固定部分不變。下面是CSS代碼段做的:在使用JS滾動時設置固定的表格頭文件

.standardTable thead tr { 
position: relative; 
top: expression(offsetParent.scrollTop); 
} 

但作爲表達式棄用鉻這同樣不鍍鉻工作。 我需要幫助改變使用JavaScript或jQuery的上述類的「頂部」屬性。

是否有可能使用javascript或jquery更改上述css中的頂級屬性。

我已經經歷了許多例子,但他們都沒有工作得很好。

(PS:我找了一行代碼,改變上面的代碼中的頂級物業)

能不能做到?

回答

0
<style> 
#ministres thead { 
    display:block; 
} 
#ministres tbody { 
    display:block; 
    height:5em; /* 5 times the equivalent of a text "size". */ 
    overflow-y:scroll; 
} 

    #ministres thead tr th:nth-child(1) { /* column 1 ! */ 
     width:5em; 
    } 
    #ministres thead tr th:nth-child(2) { /* column 2 */ 
     width:10em; 
    } 
    #ministres tbody tr:first-child td:nth-child(1) { /* column 1 ! */ 
     width:5em; 
    } 
    #ministres tbody tr:first-child td:nth-child(2) { /* column 2 */ 
     width:10em; 
    } 
</style> 
<table id="ministres" border="1"> 
    <thead> 
     <tr><th>Nom</th><th>Ministère</th></tr> 
    </thead> 
    <tbody> 
     <tr><td>JM Ayrault</td><td>Premier</td></tr> 
     <tr><td>L Fabius</td><td>A. Etrangères</td></tr> 
     <tr><td>V Peillon</td><td>Education</td></tr> 
     <tr><td>C Taubira</td><td>Justice</td></tr> 
     <tr><td>P Moscovici</td><td>Economie</td></tr> 
     <tr><td>M Valls</td><td>Intérieur</td></tr> 
    </tbody> 
</table> 

爲例這裏:http://jsfiddle.net/hweb/7eGT9/