2013-10-22 60 views
1

我试图修复html表头并滚动表体的其余部分。 对于固定列,我使用下面的CSS,但问题是,它扰乱了标题的列大小。固定滚动在html表头不干扰标题大小

<style type="text/css"> 
     div.tableContainer 
     { 
     clear: both; 
     border: 1px solid #963; 
     height: 300px; 
     overflow: hidden; 
     width: 1000px 
     } 

     html>body thead.fixedHeader tr 
     { 
     display: block 
     } 


    thead.fixedHeader th 
    { 

     background: #C96; 
    border-left: 1px solid #EB8; 
    border-right: 1px solid #B74; 
    border-top: 1px solid #EB8; 
    font-weight: normal; 
    padding: 4px 3px; 
    text-align: left 
     position: relative 
     width: 200px 

    } 

     html>body tbody.scrollContent { 
     display: block; 
     height: 300px; 
     overflow: auto; 
     width: 100% 

     } 

    tbody.scrollContent td, tbody.scrollContent tr.normalRow td { 

     background: #FFF; 
    border-bottom: none; 
    border-left: none; 
    border-right: 1px solid #CCC; 
    border-top: 1px solid #DDD; 
     padding: 2px 3px 3px 4px 

     } 

     html>body thead.fixedHeader th +th { 
    width: 50px 
     } 


    </style> 
+0

给乌尔HTML标记 – Hiral

+2

看看这个线程, http://stackoverflow.com/questions/8232713/how-to-display -scroll-BAR-到-A-HTML表 – melc

回答

0

将在一个单独的表中的标题和在另一个的内容,但位置两个表在一起,使得它看起来像一个表。

<table> 
put headers here. 
</table> 
<table> 
put content here. 
</table> 
0

尝试使用CSS属性溢出:覆盖