xhtml中table 中间自适应高度的在火狐下是没有问题的
ie下要用expression解决
height:expression(document.body.clientHeight-45 + "px" );
其中这个-45高度要根据上下高度来决定的,例子中上下高度和为30,如果把-45改为41以下则浏览器会破溃掉的,即这个值必须比上下高度和多12以上才行。
expression高度设置正确下效率没什么问题,ie内置的东西对他自己来说效率没什么问题的。
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>xhtml(dhtml)中table 中间自适应高度</title>
<style type="text/css">
html,body
{
padding:0px; margin:0px; height:100%; width:100%;
}
.autoHeight
{
height:expression(document.body.clientHeight-42 + "px" ); padding:0px; margin:0px;border:solid 1px green;
}
</style>
</head>
<body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="15" align="center">top</td>
</tr>
<tr>
<td align="center" valign="top" style="border:solid 1px red;">
<div class="autoHeight">
height:expression(document.body.clientHeight-45 + "px" );
其中这个-45高度要根据上下高度来决定的,例子中上下高度和为30,如果把-45改为41以下则浏览器会破溃掉的,即这个值必须比上下高度和多12以上才行。
</div>
</td>
</tr>
<tr>
<td height="15" align="center">bottom</td>
</tr>
</table>
</body>
</html>