2012-05-23 90 views
-1

我没有什么好的解决办法来解决它有以下类型结构的表头和列:我们怎样才能冻结HTML表第一栏和标题

<table>  
    <thead>   
     <tr>    
      <th colspan="4">Current</th>    
      <th colspan="4">New/Requested</th>   
     </tr>   
     <tr>    
      <th nowrap="nowrap">RSD &nbsp;&nbsp;&nbsp;&nbsp;</th>   
      <th nowrap="nowrap">CRSD &nbsp;&nbsp;&nbsp;&nbsp;</th>    
      <th nowrap="nowrap">MSD &nbsp;&nbsp;&nbsp;&nbsp;</th>    
      <th nowrap="nowrap">Open QTY &nbsp;&nbsp;&nbsp;&nbsp;</th>    
      <th nowrap="nowrap">CRD &nbsp;&nbsp;&nbsp;&nbsp;</th>    
      <th nowrap="nowrap">CRSD &nbsp;&nbsp;&nbsp;&nbsp;</th>   
      <th nowrap="nowrap">MSD &nbsp;&nbsp;&nbsp;&nbsp;</th>    
      <th nowrap="nowrap">Open QTY &nbsp;&nbsp;&nbsp;&nbsp;</th>    
      <th nowrap="nowrap">Action</th>    
      <th nowrap="nowrap">Reason</th>    
      <th nowrap="nowrap">Action Code Status </th>   
     </tr> 
    </thead>  
    <tbody>   
     <tr>    
      <td></td>    
      <td></td>     
      .....plenty of rows   
     </tr>  
    </tbody> 
</table> 

,并通过Ajax调用得到填充, 请提供一个很好的解决方案,我可以使用我以前的css。 (意味着它不需要任何css更改)。

+0

如果你没有在你的头使用合并单元格,此作品不错http://fixedheadertable.com/但如果你使用合并单元格时,跨越列将隐藏起来。 –

+0

只有RSD列 – user1397770

+0

这个链接是很好的解决方案,但我必须使用他们的CSS ..你能告诉我如何使用这个解决方案,而不必改变我以前的CSS(我也想修正列) – user1397770

回答

-1

你可以尝试像你的解决了这个

<table>  
    <thead>   
     <tr>    
      <th colspan="4">Current</th>    
      <th colspan="4">New/Requested</th>   
     </tr>   
     <tr>    
      <th nowrap="nowrap">RSD aaaa</th>   
      <th nowrap="nowrap">CRSD aaaa</th>    
      <th nowrap="nowrap">MSD aaaa</th>    
      <th nowrap="nowrap">Open QTY aaaa</th>    
      <th nowrap="nowrap">CRD aaaa</th>    
      <th nowrap="nowrap">CRSD aaaa</th>   
      <th nowrap="nowrap">MSD aaaa</th>    
      <th nowrap="nowrap">Open QTY aaaa</th>    
      <th nowrap="nowrap">Action</th>    
      <th nowrap="nowrap">Reason</th>    
      <th nowrap="nowrap">Action Code Status </th>   
     </tr> 
    </thead> 
</table> 
<div style='height: 150px; overflow: scroll;'> 
<table> 
    <tbody>   
     <tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr><tr>    
      <td>a</td>    
      <td>a</td>   
     </tr>  
    </tbody> 
</table> 
</div> 
+0

你是对的,但根据你的解决方案标题将显示全宽度。我需要的是该列当前 新/请求将在水平滚动时修复并且标头将被修复垂直滚动 – user1397770

0

使用CSS。

为您需要的所有列创建第一个表格,并仅显示第一个固定列值,其余列表创建另一个表格。

并为内部表给出一个特定的宽度和高度,并给出一个CSS溢出:滚动;

可能是这个链接可以帮助你理解我的意思http://www.w3schools.com/cssref/tryit.asp?filename=trycss_overflow