论坛首页 Web前端技术论坛

xhtml(dhtml)中table 中间自适应高度的一个解决方法

浏览 3157 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2010-02-22  

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>

 

论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics