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

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>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值