2013-01-08 46 views
0

如何修改CSS編碼,使第一行(頂部標題)被凍結?凍結html表格中的頂部標題行

代碼需要符合IE7標準。

table.dataTable { 
    margin: 0; 
    padding: 0; 
    border-bottom: 1px solid #999; 
    border-left: 1px solid #999; 
    color: #235A81; 
    font-family: Arial; 
    font-size: 9pt; 
} 
table.dataTable th { 
    margin: 0; 
    border-right: 1px solid #999; 
    border-top: 1px solid #999; 
    font-weight: normal; 
    padding: 4px 3px 3px 4px; 
    background: #ccc; 
    font-weight: bold; 
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#ffffff", endColorstr="#cdcdcd"); 
    text-align: left; 
    width: 150px; 
} 

table.dataTable td { 
    margin: 0; 
    border-right: 1px solid #999; 
    border-top: 1px solid #999; 
    padding: 2px 3px 3px 4px 
} 


div.scrollTableContainer { 
    height: 285px; 
    overflow: auto; 
    width: 900px; 
    margin: 15px 0 0 0; 
    position: relative; 
} 


div.scrollTableContainer table { 
    width: 952px; 
} 

div.scrollTableContainer td:last-child {padding-right: 20px;} 

div.scrollTableContainer tr:first-child td { border-top: 0; } 

div.scrollTableContainer thead th {border-bottom: 1px solid #999; } 

這裏的工作小提琴:http://jsfiddle.net/Uamhc/

+0

可能重複[HTML表與固定標頭?](http://stackoverflow.com/questions/673153/html-table-with-fixed-headers) – AndreKR

+0

可能重複[HTML表與固定標頭? ](https://stackoverflow.com/questions/673153/html-table-with-fixed-headers) –

回答

0

你需要繪製兩個表,一個與內容,一個只是頭,把頭表在一個div,並設置DIV + CSS特性: display:fixed

1

很像@ keg說你需要創建兩個表。但是,如果你有在網站的內容沒有控制權,你可以使用

$('.flexme').flexigrid(); 

導航到「例1」的this鏈接來查看如何使用它的一個例子。 :)