document.querySelectorAll('.box') 也可以取到全部的box
2016-02-26
如果不把后續(xù)的圖片填充到上一行最矮的圖片下,很可能會出現(xiàn)某幾列已經(jīng)到頁面底部而其他幾行還在上面的情況,這樣的瀑布流布局是有問題的,沒有瀑布的連貫性。
2016-02-22
獲取main下的兒子元素直接用children屬性更簡單,自己用getElementsByTagName("*"),然后遍歷就是娶不到!
2016-02-20
if(obj.currentStyle){
return obj.currentStyle[attr];
}
else{
return document.defaultView.getComputedStyle(obj,null)[attr];
}
}
return obj.currentStyle[attr];
}
else{
return document.defaultView.getComputedStyle(obj,null)[attr];
}
}
2016-02-17
//獲取CSS樣試里的值
function getStyle(obj,attr){
var ie = !+"\v1";//簡單判斷ie6~8
if(attr=="backgroundPosition"){//IE6~8不兼容backgroundPosition寫法,識別backgroundPositionX/Y
if(ie){
return obj.currentStyle.backgroundPositionX +" "+obj.currentStyle.backgroundPositionY;
}
}
function getStyle(obj,attr){
var ie = !+"\v1";//簡單判斷ie6~8
if(attr=="backgroundPosition"){//IE6~8不兼容backgroundPosition寫法,識別backgroundPositionX/Y
if(ie){
return obj.currentStyle.backgroundPositionX +" "+obj.currentStyle.backgroundPositionY;
}
}
2016-02-17
var documentH=document.documentElement.clientHeight;//頁面高度
return (lastImgH<scrollTop+documentH)?true:false;//到達指定高度后 返回true,觸發(fā)waterfall()函數(shù)
}
return (lastImgH<scrollTop+documentH)?true:false;//到達指定高度后 返回true,觸發(fā)waterfall()函數(shù)
}
2016-02-17
function checkscrollside(){
var main=document.getElementById("main");
var boxs = main.getElementsByClassName("box");
var lastImgH = boxs[boxs.length-1].offsetTop + Math.floor(boxs[boxs.length-1].offsetHeight/2);
var scrollTop=document.documentElement.scrollTop||document.body.scrollTop;//注意解決兼容性
var main=document.getElementById("main");
var boxs = main.getElementsByClassName("box");
var lastImgH = boxs[boxs.length-1].offsetTop + Math.floor(boxs[boxs.length-1].offsetHeight/2);
var scrollTop=document.documentElement.scrollTop||document.body.scrollTop;//注意解決兼容性
2016-02-17