脚本控制三行三列自适应高度DIV布局

CSS
  1. #fbox,#mbox,#sbox{
  2. width:250px;
  3. float:left;
  4. margin:0 5px;
  5. border:1px solid #009;
  6. }

HTML
  1. <body onload="P7_equalCols('fbox','mbox','sbox')">
  2. <div id="fbox">亲和力指的并不只是
  3. </div>
  4. <div id="mbox">
  5.    <br />
  6.    <br />
  7.    <br />
  8. </div>
  9. <div id="sbox">
  10. <p>亲和力指不只是关于盲人和屏幕阅读器。还有许多人虽然不是盲人,但是有视力障碍 -    你我变老时就会成为他们的一员。使网站变得更具亲和力的一个最简单的方法就是允许用户改变文字大小;拒绝提供这样的选择就剥夺了用户的主导权,很可能使用户无法舒适地阅读。 </p>的并
  11. </div>
  12. </body>
JS JS
  1. /* 
  2.   ------------------------------------------------
  3.   PVII Equal CSS Columns scripts
  4.   Copyright (c) 2005 Project Seven Development
  5.   www.projectseven.com
  6.   Version: 1.5.0
  7.   ------------------------------------------------
  8. */
  9. function P7_colH(){ //v1.5 by PVII-www.projectseven.com
  10.   var i,oh,hh,h=0,dA=document.p7eqc,an=document.p7eqa;
  11.   if(dA&&dA.length){
  12.     for(i=0;i<dA.length;i++){
  13.    dA[i].style.height='auto';
  14.     }
  15.  for(i=0;i<dA.length;i++){
  16.       oh=dA[i].offsetHeight;h=(oh>h)?oh:h;
  17.  }
  18.  for(i=0;i<dA.length;i++){
  19.    if(an){
  20.         dA[i].style.height=h+'px';
  21.    }else{
  22.      P7_eqA(dA[i].id,dA[i].offsetHeight,h);
  23.    }
  24.  }
  25.  if(an){
  26.       for(i=0;i<dA.length;i++){
  27.      hh=dA[i].offsetHeight;
  28.   if(hh>h){
  29.           dA[i].style.height=(h-(hh-h))+'px';
  30.   }
  31.    }
  32.  }else{
  33.    document.p7eqa=1;
  34.  }
  35.     document.p7eqth=document.body.offsetHeight;
  36.     document.p7eqtw=document.body.offsetWidth;
  37.   }
  38. }
  39. function P7_eqT(){ //v1.5 by PVII-www.projectseven.com
  40.   if(document.p7eqth!=document.body.offsetHeight||document.p7eqtw!=document.body.offsetWidth){
  41.     P7_colH();
  42.   }
  43. }
  44. function P7_equalCols(){ //v1.5 by PVII-www.projectseven.com
  45.   if(document.getElementById){
  46.     document.p7eqc=new Array;
  47.     for(i=0;i<arguments.length;i++){
  48.       document.p7eqc[i]=document.getElementById(arguments[i]);
  49.     }
  50.  setInterval("P7_eqT()",10);
  51.   }
  52. }
  53. function P7_eqA(el,h,ht){ //v1.5 by PVII-www.projectseven.com
  54.   var sp=10,inc=10,nh=h,g=document.getElementById(el),oh=g.offsetHeight,ch=parseInt(g.style.height);
  55.   ch=(ch)?ch:h;var ad=oh-ch,adT=ht-ad;nh+=inc;nh=(nh>adT)?adT:nh;g.style.height=nh+'px';
  56.   oh=g.offsetHeight;if(oh>ht){nh=(ht-(oh-ht));g.style.height=nh+'px';}
  57.   if(nh<adT){
  58.     setTimeout("P7_eqA('"+el+"',"+nh+","+ht+")",sp);
  59.   }
  60. }
CSDN垃圾编辑器~!~!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值