2011-02-23 40 views
0

這是帶滾動按鈕的簡單列表顯示的代碼示例。它工作良好。但現在我想凍結第一row..that是header..Can請你幫我..凍結IE 6.0和IE 7.0中的列標題

<div id="user"> 
     <table class="user_list" frame="box" bordercolor="#c1a3cf" 
         border="1" cellspacing="3" cellpadding="3"> 
      <thead> 
      <tr> 
       <th style="padding-top:15px;"> Nr. </th> 
       <th style="padding-top:15px;"> Concession Nr. </th> 
       <th style="padding-top:15px;"> Action Performed </th> 
       <th style="padding-top:15px;"> Action by </th> 
       <th style="padding-top:15px;"> Action on </th> 
      </tr> 
      </thead> 
      <tbody> 
       <?php $result = get_user_actionlog($seite,$entries); 

       if($seite == 1) { 
       $number = 0; 
       } else { 
       $number = ($seite-1) * $entries; 
       } 

      while($record = odbc_fetch_array($result)) { ?> 
       <tr> 
       <td width="25" class="rtodata"><?php $number += 1; 
         echo $number;?></td> 
      <td width="150" class="rtodata"><?php echo $record['concession']; ?> </td> 
      <td width="400" class="rtodata"><?php echo $record['action_performed'];?></td> 
      <td width="75" class="rtodata"><?php echo $record['action_by'];?></td> 
      <td width="100" class="rtodata"><?php echo $record['action_on'];?></td> 
      </tr> 
      <?php }?> 
     </tbody> 
    </table> 
</div> 

,在我的CSS文件,

#user {width: 900px;height:800px;overflow:auto;} 

編輯: -

scrollable table with fixed header在Firefox 6.0中的IE 6.0中完美工作,但不在IE 7.0中。如果你們任何一個冠軍都可以更新...

+0

你是什麼意思的「凍結?」 – Kyle 2011-02-23 07:23:30

+0

我的意思是說盡管我使用滾動條向下滾動,但標題應該固定。我應該可以看到標題。 – satya 2011-02-23 07:25:15

回答

1

環繞帶外的div然後innera..check的CSS

.outer { 
    position:relative; 
    padding:4em 0 3em 0; 
    width:54em; 
    background:bottom; 
    margin:0 auto 3em auto; 
} 
.innera { 
    overflow:auto; 
    width:54em; 
    height:9.6em; 
    background:#eee; 
    border:2px gray; 
} 
.outer thead tr { 
    position:absolute; 
    top:2em; 
    height:1.5em; 
    left:0; 

} 
.outer th, .outer td { 
    width:10em; 
    text-align:left; 

表我測試的代碼,它是工作。測試在IE 6.0,7.0 ++。代碼是從互聯網:-)

1

你可以通過在<thead>中添加一個類並使用position: fixed;來完成。你需要添加一些填充到你的div中,使其顯示,如你所願。

Example for you here


IE並不擅長配套 什麼 滾動表。以這種方式編輯表格在任何情況下都不是一個好主意。你可以用一個表格把你的TH包裹在一個div中,然後把你的信息放在另一個表格中,用另一個div來溢出自動

Another example

這不是完美的,因爲你有很多關於HTML視覺屬性,你應該擺脫這些,只使用CSS。但這是基本功能,它應該可以在所有瀏覽器中運行。

+0

+1,謝謝你的回覆。但我已經嘗試過你的例子,列標題不固定。你能再請檢查一下嗎? – satya 2011-02-23 08:07:27

+0

查看示例,標頭非常多:)您使用哪種瀏覽器?我在Chrome,FF和IE8測試。 – Kyle 2011-02-23 08:08:17

+0

對不起,我忘了寫關於瀏覽器..我在IE 7.0中檢查。標題不固定。在Mozilla 3.6.13頭文件中是固定的......但在向下滾動時,數據流過頭文件信息。你能找到一個解決IE 6.0和IE 7.0 – satya 2011-02-23 08:14:31