DIVCSS網(wǎng)頁布局:三行三列自適應(yīng)高度的DIV布局_Div+CSS教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
示例代碼 [hl5o.cn]
這個(gè)例子是用JS腳本控制并列DIV的高度,通常在DIV布局中,自適應(yīng)高度一直是比較頭疼的問題,一般大都采用背景圖、外套DIV、右欄覆蓋左欄來解決�,F(xiàn)在加了腳本后,簡單多了,假如有三個(gè)水平并列的DIV,fbox、mbox、sbox,只要在<body>標(biāo)簽中寫入:onload="P7_equalCols('fbox','mbox','sbox')",測試條件:ie5.x、ie6.0、FF1.03、NS7.2、opera8.01
JS代碼:版權(quán)歸原作者,僅供學(xué)習(xí)研究.
示例代碼 [hl5o.cn]
/*
------------------------------------------------
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);}
}
------------------------------------------------
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);}
}
最終效果
代碼調(diào)試框 [hl5o.cn]
[ 可先修改部分代碼 再運(yùn)行查看效果 ]
相關(guān)Div+CSS教程:
- DIV+CSS設(shè)計(jì)的誤區(qū)
- CSS基礎(chǔ):常用CSS英文字體介紹
- IE6和IE7中border邊框斷線現(xiàn)象
- border:none;與border:0;的有什么不同?
- div+css下js對聯(lián)廣告不隨屏幕滾動(dòng)的解決方法
- HTML元素的ID和Name屬性的區(qū)別
- divcss教程:深入了解css的行高Line Height屬性
- CSS文檔流,塊級元素和內(nèi)聯(lián)元素
- 5個(gè)你該知道的CSS3新技術(shù)
- 用正則表達(dá)式替換a標(biāo)記href值
- 30個(gè)優(yōu)秀的CSS導(dǎo)航和按鈕設(shè)計(jì)教程
- css中px和em有什么區(qū)別
Div+CSS教程Rss訂閱Div+Css教程搜索
Div+CSS教程推薦
- border:none;與border:0;的有什么不同?
- Div CSS布局應(yīng)該注重語義、注重代碼的重用性!
- divcss表單布局技巧及CSSForm表單設(shè)計(jì)技巧
- CSS實(shí)戰(zhàn):id是狙擊槍class是雙刃劍合則兩利分則兩敗
- DivCSS教程:blockelement與inlineelement元素詳解
- DIVCSS中id于class的區(qū)別詳解
- divcss三列橫向排列實(shí)例代碼
- 為什么要Web標(biāo)準(zhǔn)化,有何價(jià)值?
- CSS網(wǎng)頁布局經(jīng)驗(yàn):富有語義地類class和id標(biāo)記命名
- HTML元素的ID和Name屬性的區(qū)別
猜你也喜歡看這些
- CSS JavaScript打造鼠標(biāo)懸停圖片漸顯效果!
- CSS基礎(chǔ)實(shí)例:CSS實(shí)現(xiàn)帶背景圖片的文字鏈接的方法
- CSS實(shí)例:三列自適應(yīng)等高且中列寬度自適應(yīng)
- CSS網(wǎng)站風(fēng)格設(shè)計(jì)實(shí)例HuDong123
- CSS實(shí)例教程:CSS橫向菜單會動(dòng)的小豎條
- CSSFloatLayoutBasics-CSS浮動(dòng)布局基礎(chǔ)
- CSS布局教程:用DIV CSS實(shí)現(xiàn)國內(nèi)經(jīng)典式三行兩列布局
- CSS布局實(shí)例:一個(gè)不錯(cuò)的表格樣式
- DIV CSS布局入門示例(三)頁面頂部制作
- DIV CSS JS仿kijiji導(dǎo)航條
- 相關(guān)鏈接:
- 教程說明:
Div+CSS教程-DIVCSS網(wǎng)頁布局:三行三列自適應(yīng)高度的DIV布局
。