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一樣,如果要實現width: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%;width: 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%;width: 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