2011-03-07 74 views
0

如何獲取具有最大高度的子/嵌套表可滾動的表?我不希望thead滾動它。我真正尋找的是一些有效的標籤,我可以在我的包裹S,或其他標記,將工作一樣好了這一點:滾動HTML嵌套表

<table> 
    <thead> 
     <tr> 
      <th>Column1</th> 
      <th>Column2</th> 
     </tr> 
    </thead> 
    <!-- Insert valid tag here to wrap <tbody>s --> 
    <tbody> 
     <tr> 
      <td>Val1</td> 
      <td>Val2</td> 
     </tr> 
     <tr class="sub-table"> 
      <td colspan="2"> 
       <table> 
        <thead> 
         <tr> 
          <th>Sub Column1</th> 
          <th>Sub Column2</th> 
         </tr> 
        </thead> 
        <tbody> 
         <tr> 
          <td>Sub Val1</td> 
          <td>Sub Val2</td> 
         </tr> 
        </tbody> 
       </table> 
      </td> 
     </tr> 
    </tbody> 
    <tbody> 
     <tr> 
      <td>Val1</td> 
      <td>Val2</td> 
     </tr> 
     <tr class="sub-table"> 
      <td colspan="2"> 
       <table> 
        <thead> 
         <tr> 
          <th>Sub Column1</th> 
          <th>Sub Column2</th> 
         </tr> 
        </thead> 
        <tbody> 
         <tr> 
          <td>Sub Val1</td> 
          <td>Sub Val2</td> 
         </tr> 
        </tbody> 
       </table> 
      </td> 
     </tr> 
    </tbody> 
    <!-- Insert valid close tag here --> 
</table> 
+0

您是否希望嵌套表的TBODY滾動,但嵌套表的THEAD保持固定,還是隻應保持主表的THEAD固定? – FarligOpptreden 2011-03-07 08:14:32

回答

0

如果我正確理解你的問題,也許嘗試的東西像這樣:http://jsfiddle.net/pPuXL/1/

您需要將TBODY元素顯示爲「block」或「inline-block」才能使溢出生效,就像在我發佈的CSS示例中一樣。