国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 網頁設計 > 正文

腳本控制三行三列自適應高度DIV布局

2024-08-30 08:36:30
字體:
來源:轉載
供稿:網友

這個例子是用JS腳本控制并列DIV的高度,通常在DIV布局中,自適應高度一直是比較頭疼的問題,一般大都采用背景圖、外套DIV、右欄覆蓋左欄......來解決。現在加了腳本后,簡單多了,假如有三個水平并列的DIV,fbox、mbox、sbox,只要在<body>標簽中寫入:onload="P7_equalCols('fbox','mbox','sbox')",測試條件:ie5.x、ie6.0、FF1.03、NS7.2、opera8.01

JS代碼:版權歸原作者,僅供學習研究.

 

以下是引用片段:
/* 
------------------------------------------------ 
PVII Equal CSS Columns scripts 
Copyright (c) 2005 Project Seven Development 
www.projectseven.com 
Version: 1.5.0 
------------------------------------------------ 
*/ 
function P7_colH(){ //v1.5 by PVII-www.projectseven.com 
var i,oh,hh,h=0,dA=document.p7eqc,an=document.p7eqa;if(dA&&dA.length){ 
for(i=0;i<dA.length;i++){dA[i].style.height='auto';}for(i=0;i<dA.length;i++){ 
oh=dA[i].offsetHeight;h=(oh>h)?oh:h;}for(i=0;i<dA.length;i++){if(an){
dA[i].style.height=h+'px';}else{P7_eqA(dA[i].id,dA[i].offsetHeight,h);}}if(an){ 
for(i=0;i<dA.length;i++){hh=dA[i].offsetHeight;if(hh>h){ 
dA[i].style.height=(h-(hh-h))+'px';}}}else{document.p7eqa=1;} 
document.p7eqth=document.body.offsetHeight; 
document.p7eqtw=document.body.offsetWidth;} 

function P7_eqT(){ //v1.5 by PVII-www.projectseven.com 
if(document.p7eqth!=document.body.offsetHeight||document.p7eqtw! =document.body.offsetWidth){ 
P7_colH();} 

function P7_equalCols(){ //v1.5 by PVII-www.projectseven.com 
if(document.getElementById){document.p7eqc=new Array;for(i=0;i<arguments.length;i++){ 
document.p7eqc[i]=document.getElementById(arguments[i]);} setInterval("P7_eqT()",10);} 

function P7_eqA(el,h,ht){ //v1.5 by PVII-www.projectseven.com 
var sp=10,inc=10,nh=h,g=document.getElementById(el),oh=g.offsetHeight,ch=parseInt(g.style.height) ; 
ch=(ch)?ch:h;var ad=oh-ch,adT=ht-ad;nh+=inc;nh=(nh>adT)?adT:nh;g.style.height=nh+'px'; 
oh=g.offsetHeight;if(oh>ht){nh=(ht-(oh-ht));g.style.height=nh+'px';} 
if(nh<adT){setTimeout("P7_eqA('"+el+"',"+nh+","+ht+") ",sp);} 
}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 舞阳县| 志丹县| 揭西县| 桓台县| 阳山县| 涪陵区| 蒲江县| 灌南县| 定安县| 武清区| 恩平市| 新丰县| 澎湖县| 三门县| 岳阳县| 文山县| 广州市| 邮箱| 皋兰县| 岳普湖县| 调兵山市| 景谷| 康马县| 罗田县| 北票市| 清镇市| 潜江市| 泰来县| 德令哈市| 定西市| 拜泉县| 平顺县| 利川市| 上林县| 临邑县| 德江县| 长宁区| 通化县| 仙桃市| 拉孜县| 嘉兴市|