日期:2014-05-16 浏览次数:20362 次
<!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>
<script language=javascript>
//******************************************************************
//参数BossID 指定大容器的ID
//参数BossName 指定大容器ID内的小容器名称
//shengming D放大 X缩小 不是D或X就把容器高度设定为28px
//******************************************************************
function ZiYouHigh(BossID,BossName,shengming) {
var MuBiao = document.getElementById(BossID).getElementsByTagName(BossName);
for (var i = 0; i < MuBiao.length; i ++) {
var RongQiJiuHigh=MuBiao[i].offsetHeight;
MuBiao[i].style.Height=RongQiJiuHigh+"px"; //先获取当前容器高度
var HighDuShu = MuBiao[i].style.Height;
HighDuShu=HighDuShu.substr(0,HighDuShu.length-2); //去掉px字符
if(shengming == "da")
{ var RongQiXinHigh=RongQiJiuHigh + 1; }
else if(shengming == "xiao")
{ var RongQiXinHigh=RongQiJiuHigh - 1; }
else
{ var RongQiXinHigh=28;}
MuBiao[i].style.Height=RongQiXinHigh+"px"; //调整容器高度
MuBiao[i].style.lineHeight=RongQiXinHigh+"px"; //调整容器上下居中
}
}
</script>
</head>
<body>
<h5>是不是可以更精简一些?</h5>
<table width="500" border="1" bordercolor="#CCCCCC" id="CEshi">
<tr>
<td>A</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>B</td>
<td> </td>