• js-小效果-瀑布流


    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>无标题文档</title>
    <style>
    *{
    margin:0;
    padding:0;
    list-style:none;
    }
    #box {
    margin: 0 auto;
    966px;
    height:auto;
    overflow:hidden;
    }

    #box ul {
    200px;
    border: #000 1px solid;
    float: left;
    margin-right: 20px;
    }

    #box ul li {
    180px;
    margin: 10px 9px;
    border: #666 1px solid;
    }
    </style>
    <script>
    function rnd(n,m){
    return parseInt(Math.random() * (m - n) + n);
    }
    function createLi(){
    var oLi = document.createElement('li');
    oLi.style.height = rnd(100,400) + 'px';
    oLi.style.background = 'rgb('+rnd(0,256)+','+rnd(0,256)+','+rnd(0,256)+')';
    return oLi;
    }
    window.onload = function(){
    var oBox = document.getElementById('box');
    var aUl = oBox.children;

    function appendLi(){
    for(var i = 0; i < 20; i++){
    var oLi = createLi();
    var arrUl = [];
    for(var j = 0; j < aUl.length; j++){
    arrUl[j] = aUl[j];
    }
    arrUl.sort(function(n1,n2){
    return n1.offsetHeight - n2.offsetHeight;
    });
    arrUl[0].appendChild(oLi);
    }
    }
    appendLi();
    window.onscroll = function(){
    var oscrollH = document.documentElement.scrollTop || document.body.scrollTop;
    var clientH = document.documentElement.clientHeight;
    var oBoxH = oBox.scrollHeight;
    if(oscrollH + clientH >= oBoxH - 300){
    appendLi();
    }
    }
    }
    </script>
    </head>

    <body>
    <div id="box">
    <ul></ul>
    <ul></ul>
    <ul></ul>
    <ul></ul>
    </div>
    </body>
    </html>
  • 相关阅读:
    bzoj4183: tree
    bzoj4389: ZYB and Trees
    bzoj3253: 改编
    uoj#274. 【清华集训2016】温暖会指引我们前行
    uoj#272. 【清华集训2016】石家庄的工人阶级队伍比较坚强
    uoj#11. 【UTR #1】ydc的大树
    uoj#29. 【IOI2014】Holiday
    uoj#187. 【UR #13】Ernd
    bzoj5019: [Snoi2017]遗失的答案
    bzoj5017: [Snoi2017]炸弹
  • 原文地址:https://www.cnblogs.com/HUANGRONG888/p/6059474.html
Copyright © 2020-2023  润新知