2012-03-17 49 views
8

在我的網站上,在某些頁面上,有一個表格列出了一些信息。如果有6個項目要顯示,那麼包含信息的表格單元格應該有一個滾動條 - 單元格不應該展開。最大高度不能在桌子上工作

所以,我有以下佈局:

<table style="overflow-y:scroll"> //this contains multiple boxes for different topics 
    <tr style="overflow-y:scroll;max-height:200px;"> //this contains one topic of info 
     <td style="overflow-y:scroll;max-height:200px;"> //This contains one topic of info 
      <table style="overflow-y:scroll;max-height:200px;"> //contains one topic with several items 
       <tr><td>OneItem</td></tr> 
       <tr><td>AnotherItem</td></tr> (and say, this goes on for 10 items) 
      </table> 
     </td> 
    </tr> 
    //the outermost <tr> would repeat itself here, say 5 times for each of a few different topics. 
</table> 

但是,這不幸的是,結果在一個盒子裏是較大的伸展不斷爲每個新產品加入。如果它有足夠的物品。 (當更新完成時,我將使用CSS和overflow-y:auto,但是爲了更好的測試目的,我正在使用它)。

我最初只用一個外表嘗試它,但佈局比我在此處顯示的稍微複雜一點,所以單個外表不會根據需要顯示。

但我需要的是知道如何使最大高度防止<tr>,<td><table>伸展。

任何幫助,非常感謝。

+0

我在G-Chrome和Firefox測試。 – Jakar 2012-03-17 20:14:39

回答

10

我添加了一個<div>最外層<td>內:

<table> //this contains multiple boxes for different topics 
    <tr> //this contains one topic of info 
     <td> //This contains one topic of info 
     <div style="overflow-y:scroll;max-height:200px;"> 
      <table> //contains one topic with several items