第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

oParent.style.cssText = 'width:' + oBoxW*cols +'px;margin:0 auto';在瀏覽器里沒有效果,console.log()也沒有輸出內(nèi)容,有人知道這是怎么回事嗎?

<!DOCTYPE?html>
<html>
<head>
????<meta?charset="UTF-8">
????<title>2.1HTML?CSS實(shí)現(xiàn)瀑布流布局頁面</title>
????<link?rel="stylesheet"?type="text/css"?href="css/style.css">
????<script?type="text/javascript">
????window.load?=?function(){
????????waterfall("main","box");
????};
????function?waterfall(parent,box){
????????//將main下所有class為box的元素取出來
????????var?oParent?=?document.getElementById(parent);
????????var?oBoxs?=?getByClass(oParent,box);
????????//?console.log(oBoxs.length);
????????//?計(jì)算整個(gè)頁面顯示的列數(shù)(頁面寬/box的寬)
????????var?oBoxW?=?oBoxs[0].offsetWidth;
????????//?console.log(oBoxW);
????????var?cols?=?Math.floor(document.documentElement.clientWidth/oBoxW);
????????//console.log(cols);
????????//設(shè)置mian的寬度
????????oParent.style.cssText?=?'width:'?+?oBoxW*cols?+'px;margin:0?auto';
????}
????//根據(jù)class獲取元素
????function?getByClass(parent,clsName){
????????var?boxArr?=?new?Array();//用來存儲獲取到的所有class為box的元素
????????var?oElements?=?parent.getElementsByTagName('*');
????????for?(var?i?=?0;?i?<?oElements.length;?i++)?{
????????????if(oElements[i].className?==?clsName){
????????????????boxArr.push(oElements[i]);
????????????}
????????}
????????return?boxArr;
????}
????</script>
</head>
<body>
????<div?id="main">
????????<div>
????????????<div>
????????????????<img?src="images/P_00.jpg">
????????????</div>
????????</div>
????????<div>
????????????<div>
????????????????<img?src="images/P_01.jpg">
????????????</div>
????????</div>
????????<div>
????????????<div>
????????????????<img?src="images/P_02.jpg">
????????????</div>
????????</div>
????????<div>
????????????<div>
????????????????<img?src="images/P_03.jpg">
????????????</div>
????????</div>
????????<div>
????????????<div>
????????????????<img?src="images/P_04.jpg">
????????????</div>
????????</div>
????????<div>
????????????<div>
????????????????<img?src="images/P_05.jpg">
????????????</div>
????????</div>
????????<div>
????????????<div>
????????????????<img?src="images/P_06.jpg">
????????????</div>
????????</div>
????????<div>
????????????<div>
????????????????<img?src="images/P_07.jpg">
????????????</div>
????????</div>
????????<div>
????????????<div>
????????????????<img?src="images/P_08.jpg">
????????????</div>
????????</div>
????????<div>
????????????<div>
????????????????<img?src="images/P_09.jpg">
????????????</div>
????????</div>
????????<div>
????????????<div>
????????????????<img?src="images/P_010.jpg">
????????????</div>
????????</div>
????????<div>
????????????<div>
????????????????<img?src="images/P_011.jpg">
????????????</div>
????????</div>
????????<div>
????????????<div>
????????????????<img?src="images/P_012.jpg">
????????????</div>
????????</div>
????????<div>
????????????<div>
????????????????<img?src="images/P_013.jpg">
????????????</div>
????????</div>
????????<div>
????????????<div>
????????????????<img?src="images/P_014.jpg">
????????????</div>
????????</div>
????????<div>
????????????<div>
????????????????<img?src="images/P_015.jpg">
????????????</div>
????????</div>
????????<div>
????????????<div>
????????????????<img?src="images/P_016.jpg">
????????????</div>
????????</div>
????????<div>
????????????<div>
????????????????<img?src="images/P_017.jpg">
????????????</div>
????????</div>
????????<div>
????????????<div>
????????????????<img?src="images/P_018.jpg">
????????????</div>
????????</div>
????????<div>
????????????<div>
????????????????<img?src="images/P_019.jpg">
????????????</div>
????????</div>
????</div>
</body>
</html>

我跟著老師寫的代碼里,不會出現(xiàn)固定寬度,即oParent.style.cssText = 'width:' + oBoxW*cols +'px;margin:0 auto';在瀏覽器里沒有效果,另,在控制臺上,console.log()也沒有輸出內(nèi)容,有哪位知道這是怎么回事嗎?

正在回答

4 回答

window.onload=function(){
? waterfall('main','box');
}

是onload不是load? 改下效果就出來了



0 回復(fù) 有任何疑惑可以回復(fù)我~

你的console.log()沒有輸出內(nèi)容,是因?yàn)槟惆堰@行代碼注釋了,所以在控制臺沒有出現(xiàn)你想要的效果。

我的也是在設(shè)置main的固定寬度出了問題,不知道是不是兼容性的問題。

0 回復(fù) 有任何疑惑可以回復(fù)我~

是ie瀏覽器嗎?ie不支持的吧

0 回復(fù) 有任何疑惑可以回復(fù)我~

你這個(gè)發(fā)現(xiàn)是什么問題了嗎,我的也是這個(gè)問題,oparent.style,cssText='width:'+oBoxW*cols+'px'沒反應(yīng)沒效果

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

oParent.style.cssText = 'width:' + oBoxW*cols +'px;margin:0 auto';在瀏覽器里沒有效果,console.log()也沒有輸出內(nèi)容,有人知道這是怎么回事嗎?

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號