<div id='scrollDiv' style='DISPLAY: inline; OVERFLOW: auto; WIDTH: 100%; CURSOR: default; HEIGHT: 800px'>我想实现一个固定表头的table,用div嵌套
在HEIGHT: 800px情况下可行,但用户不想固定高度我尝试用HEIGHT: 100%就功能不行了请问如何根据实际高度给div设置高度呢?

解决方案 »

  1.   

    要用脚本设.
    如scrollDiv.style.height = document.getElementById("table2").offsetHeight;
      

  2.   

    看看这个对你可能会有点用
    http://blog.csdn.net/cpp2017/archive/2007/02/03/1501636.aspx
      

  3.   

    你说的其实是 “Div高度自适”!高度100%的绝对定位自适应布局
    文章来源于 《高度100%的绝对定位自适应布局》
    http://www.blueidea.com/bbs/NewsDetail.asp?lp=1&id=2494868 http://www.rexsong.com/blog/article.asp?id=165 
    或者
    http://www.blueidea.com/tech/web/2006/3131.asp 方法1
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>Untitled Document</title>
    </head><body style="height:100%; margin:0;"><div style="width:100%; margin:0 auto; text-align:center; background:#FF9400; height:100px; position:absolute; top:0; line-height:100px;">head</div><div style="width:100%; margin:0 auto; background:#eee; height:100%;">
        <div style="height:101px; background:#fff;"></div>
            
        <div style="height:101px; background:#eee;"></div>
    </div><div style="width:100%; margin:0 auto; text-align:center; background:#f00; height:100px; position:absolute; bottom:0; line-height:100px;">foot</div></body>
    </html>
    方法2
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
        
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <title></title>
        <style type="text/css">
        body,html{
            height: 100%;
            padding: 0;
            margin: 0;
        }
        #header,#footer{
            height: 10%;
            background: #EBF7F9;
        }
        
        #container{
            min-height: 80%;
            background: #FDF5E6;        
        }
        /*\*/
        * html #container{
            height: 80%;
        }
        /**/
        </style>
    </head><body>
    <div id="header">...</div>
    <div id="container">
     <div id="mainbg">
      <div id="left">...</div>
      <div id="right">...Cellular Technologies 
    Cell line development 
    Engineered cell-based assays 
    Cell based assays are an essential tool in understanding biological pathways especially when linked to high throughput readouts. Native cell lines or cells engineered to express foreign reporter genes can be used to read out a biological target or pathway or to confirm the activity and mechanism of action of drug candidates. Dragonfly has extensive experience in establishing known cell-based assays or developing new ones.Examples of engineered cells and assays which Dragonfly has experience in include:Heterologous or chimeric receptor growth factor assays. Growth factor dependent cells can convenient cellular bioassays for growth factors or cytokines. Dragonfly has engineered heterologous human or rodent receptors into factor dependent cells as stable transformants to provide a readouts for ligand induced receptor activation or to assay small molecule or antibody antagonists. We have also engineered chimeric receptors with novel extracellular domains linked to a signaling intracellular domain to derive ligand dependent cell lines. 
    Engineered reporter cell assays. Reporter genes may be used to monitor promoter activity, the expression of tagged proteins, or to read out a biological pathway. Dragonfly has experience with multiple cell types engineered to express a variety of epitope tagged proteins or reporter proteins adapted to high throughput, 96 well assays. Examples of epitope tags or reporters we have worked with include: FLAG, His6, myc, GFP and lac Z. 
    </div>
     </div>
    </div>
    <div id="footer">...</div></body>
    </html>
      

  4.   

    看看这个对你可能会有点用
    http://blog.csdn.net/cpp2017/archive/2007/02/03/1501636.aspx---------------------------------------------------------------------
    这个我看过了
    但我是html table填充的数据滚动,好像有点区别- -#