日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

瀑布流 颜色随机 加载滚动

發布時間:2024/4/17 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 瀑布流 颜色随机 加载滚动 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>無標題文檔</title>
<style>
*{margin:0;padding:0}
#box{width:700px;margin:0 auto;}
#box ul{width:198px; float:left; border:1px solid #000;margin-right:50px;}
#box ul li{ list-style:none; font-size:100px; color:#fff;}
</style>
<script>
function test()
{
var oBox=document.getElementById('box');
var aUl=oBox.children;
var n=0;
//每次20個
for(var i=0;i<20;i++)
{

function rnd(n,m)
{
return parseInt(Math.random()*(m-n+1)+n);
};
var oLi=document.createElement('li');
n++;
oLi.innerHTML=n;
oLi.style.height=rnd(100,400)+'px';
oLi.style.background='rgb('+rnd(0,255)+','+rnd(0,255)+','+rnd(0,255)+')';
//找最小的UL
var oUl;
if(aUl[0].offsetHeight<aUl[1].offsetHeight)
{
if(aUl[0].offsetHeight<aUl[2].offsetHeight)
{
oUl=aUl[0];
}
else
{
oUl=aUl[2];
};
}
else
{
if(aUl[1].offsetHeight<aUl[2].offsetHeight)
{
oUl=aUl[1];
}
else
{
oUl=aUl[2];
};
};
oUl.appendChild(oLi);
};

}


window.οnlοad=function ()
{ test();
}


//滾動條在Y軸上的滾動距離
function getScrollTop(){
  var scrollTop = 0, bodyScrollTop = 0, documentScrollTop = 0;
  if(document.body){
    bodyScrollTop = document.body.scrollTop;
  }
  if(document.documentElement){
    documentScrollTop = document.documentElement.scrollTop;
  }
  scrollTop = (bodyScrollTop - documentScrollTop > 0) ? bodyScrollTop : documentScrollTop;
  return scrollTop;
}

//文檔的總高度
function getScrollHeight(){
  var scrollHeight = 0, bodyScrollHeight = 0, documentScrollHeight = 0;
  if(document.body){
    bodyScrollHeight = document.body.scrollHeight;
  }
  if(document.documentElement){
    documentScrollHeight = document.documentElement.scrollHeight;
  }
  scrollHeight = (bodyScrollHeight - documentScrollHeight > 0) ? bodyScrollHeight : documentScrollHeight;
  return scrollHeight;
}

//瀏覽器視口的高度
function getWindowHeight(){
  var windowHeight = 0;
  if(document.compatMode == "CSS1Compat"){
    windowHeight = document.documentElement.clientHeight;
  }else{
    windowHeight = document.body.clientHeight;
  }
  return windowHeight;
}


window.onscroll = function(){
  if(getScrollTop() + getWindowHeight() >= getScrollHeight()-300){
// alert("you are in the bottom!");
test()
  }
};


</script>
</head>

<body>

<div id="box">
<ul></ul>
<ul></ul>
<ul style="margin:0;"></ul>
</div>
<div class="footer" id="bm">

?

</body>
</html>

轉載于:https://www.cnblogs.com/moliwanzi/p/3939852.html

總結

以上是生活随笔為你收集整理的瀑布流 颜色随机 加载滚动的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。