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

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

圖片在滾動(dòng)之后疊加在一起了

//?JavaScript?Document
//第一步獲取元素
window.onload=function(){
	var?main=document.getElementById('main');
	var?box=getName(main,'box');
	var?dataInt={"data":[{"src":'P_00.jpg'},
	{"src":'P_01.jpg'},
	{"src":'P_02.jpg'},
	{"src":'P_03.jpg'},
	{"src":'P_04.jpg'}]}
window.onscroll=function(){?
	if(checkedit){
		for(var?i=0;i<dataInt.data.length;i++){
	var?cbox=document.createElement('div');
	cbox.className='box';
	main.appendChild(cbox);
	var?cpic=document.createElement('div');
	cpic.className='pic';
	cbox.appendChild(cpic);
	var?cimg=document.createElement('img');
	cimg.src="images/"+dataInt.data[i].src;
	cpic.appendChild(cimg);
		}
	waterfull();	
	}
	
}//onscroll
function?waterfull(){
	//console.log(box.length);
//第二步?將圖片放到高度最小的圖片下面
var?cols=Math.floor(document.documentElement.clientWidth/box[0].offsetWidth);
//列數(shù)
var?hrry=[];
//新建數(shù)組用來儲(chǔ)存高度值
for(var?i=0;i<box.length;i++){
	if(i<cols){
		hrry.push(box[i].offsetHeight);
		
		}	
	?else{
		var?minH=Math.min.apply(null,hrry);
		var?index=getIndex(hrry,minH);
		box[i].style.position='absolute';
		box[i].style.top=minH+'px';
		//box[i].style.left=cols*index+'px';
		box[i].style.left=box[index].offsetLeft+'px';
		hrry[index]+=box[i].offsetHeight;
		console.log(hrry);
		}	
	}
}//waterfull
//獲取高度值最小的序號(hào)
function?getIndex(arry,val){
	for(i?in?arry){
		if(arry[i]==val){
			return?i;
			}
		}
	}
//獲取class名的元素	
function?getName(parent,child){
	var?arry=[];
	var?ele=parent.getElementsByTagName('*');
	for(var?i=0;i<ele.length;i++){
		if(ele[i].className==child){
			arry.push(ele[i]);
			}
		}
		return?arry;
	}//getname
//檢查是否應(yīng)該加載圖片
function?checkedit(){
	var?lastbox=box[box.length-1];
	var?boxh=lastbox.offsetTop+Math.floor(lastbox.offsetHeight/2);
	var?mainh=document.body.clientHeight||document.documentElement.clientHeight;
	var?scrolltop=document.body.scrollTop||document.documentElement.scrollTop;
	return?(boxh<scrolltop+mainh)?true:false;
	}			
}


正在回答

3 回答

是不是css里面寫錯(cuò)了,應(yīng)該為相對(duì)定位

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

43行寫了絕對(duì)定位

box[i].style.position='absolute';


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

沒有絕對(duì)定位吧

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

舉報(bào)

0/150
提交
取消

圖片在滾動(dòng)之后疊加在一起了

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

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

幫助反饋 APP下載

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

公眾號(hào)

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