zoukankan      html  css  js  c++  java
  • table height设为100%后高度没有全屏显示

    What does 100% height means?

     Setting the 100% height of the table means the table will occupy 100% of the available space vertically. Here available space means space of it's parent control. If the height of the parent control is not 100% then height of the table couldn't be 100%.

    If you are trying to set 100% height of the table directly contained the body of a html page the you need to first set the height of the body and html. The below code will work perfectly fine for the 100% table height.

    关键是下面前两行

    <html style="height: 100%;">

    <body style="height: 100%;">

    <table style="height: 100%;">

      <tr>   

        <td>....</td>  

    </tr>

    </table>

    </body>

    </html>

    If you are using css then html, body {   height: 100%; }

    This will work in almost all browser

    转自:http://www.dailycoding.com/Posts/howtoset100tableheightinhtml.aspx

    上面设置后在ie6下正常,在ie8的兼容模式下也可以,但用ie8或firefox、opera等还是不行,参看下面,将指定的网页是遵循什么标准语句删除即可。

    table和div设置height:100%无效的完美解决方法

    刚接触网页排版的新手,常出现这种情况:设置table和div的高height="100%"无效,使用CSS来设置height:"100%"也无效,为什么会这样呢?解决height:100%无效,table和div的解决方法并不相同。

    首先说一下table,他比较容易解决,当我们使用Dreamweaver来制作网页,新建一张网页,通常在代码头部会有类似以下的代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 没错,你猜对了,问题就出在这里,你试着把这短代码删除,然后再刷新一下网页,你就会看到所有table以你的设置height="100%"的展示! 这段代码是告诉浏览器你的网页是遵循什么标准的,如上面的“W3C”标准,删除掉一般是不影响的。 下面说一下div,div和table一样,如果要实现100%是很容易的,但要div的height:"100%",它就不大听话了,其实不是它不听话,是你不知道让它听话的方法。如下代码: <!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>测试</title> </head> <body> <div style="height:100%"></div> </body> </html> 就算和Table一样去掉头部的那段代码也不能100%显示,原因很简单,你让div的height="100%",执行网页时,css先执行到,而整个网页中的内容还没有完全载入,是获取不到div外面的<body>等的高度的,所以height="100%"也就不能如愿显示了。加上 body{height:100%} 就轻松解决啦,一开始就让body以100%显示,他的下级div自然就100%的,不过对于FF浏览器还应该把HTML也先给height:100%,即 html,body{height:100%}

      Html代码   <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title> New Document </title> <style type="text/css">  html { height: 100%}  body {height:100%;margin:0px;padding:0px}  table{height: 100%; 100%;} </style> </head>

    <body> <table border=1> <tr> <td> <ul> <li>12 <li>34 </ul> </td> <td> <iframe name="" src="" width="100%" height="100%"></iframe> </td> </tr> </table> </body> </html> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html>  <head>   <title> New Document </title>   <style type="text/css">     html { height: 100%}     body {height:100%;margin:0px;padding:0px}     table{height: 100%; 100%;}   </style>  </head>

     <body>     <table border=1>         <tr>             <td>                 <ul>                     <li>12                     <li>34                 </ul>             </td>             <td>                 <iframe name="" src="" width="100%" height="100%"></iframe>             </td>         </tr>     </table>  </body> </html>

    以上转自;http://blog.csdn.net/majin_com/archive/2011/04/12/6318499.aspx

  • 相关阅读:
    Styling a Flex Button control using embedded fonts(转载)
    ArcSDE Administration Command Reference (来自ARCGIS官方)
    FlexPaper_1.2.1.swc——Flex在线显示PDF文档(使用FlexPaper)感悟
    SDE数据的备份与恢复(转载)
    C#中将dll汇入exe,并加壳(转载)
    WEB页面导出为EXCEL/WORD文档的方法 (转载)
    Property Manager Updated 1.0.0.4 小工具介绍(转载)
    Openbravo 3.0安装过程简述
    Installing "uuidossp" library in Postgres 9.1
    BindingSource的事件触发顺序
  • 原文地址:https://www.cnblogs.com/enjoyprogram/p/2676379.html
Copyright © 2011-2022 走看看