• 瀑布流


    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>瀑布流</title>
        <style type="text/css">
            *{
                margin: 0;
                padding: 0;
            }
            ul{
                list-style: none;
            }
            .clearfix:after{
                content: "";
                display: block;
                clear: both;
            }
    
            .list{
                width: 1000px;
                margin: 30px auto;
            }
    
            .list ul{
                float: left;
                width: 320px;
            }
    
            .list .c{
                margin: 0 20px;
            }
            .list li{
                margin-bottom: 10px;
                font-size: 20px;
            }
        </style>
    </head>
    <body>
        <div class="list clearfix" id="list">
            <ul></ul>
            <ul class="c"></ul>
            <ul></ul>
        </div>
        <script type="text/javascript">
            var oList=document.getElementById('list');
            var aUl=oList.getElementsByTagName('ul');
            var now=1;
            var arr=[];
    
            function creatEle(){
                var oLi=document.createElement('li');
                oLi.style.height=parseInt(Math.random()*250+70)+'px';
                var r=parseInt(Math.random()*255),
                    g=parseInt(Math.random()*255),
                    b=parseInt(Math.random()*255);
                    oLi.style.backgroundColor='rgb('+r+','+g+','+b+')';
                    oLi.innerHTML=now+'是件大事看几点睡的深刻的解释道';
                    now++
    
                    for(var i=0; i<aUl.length; i++){
                        arr[i]=aUl[i];
                    }
    
                    arr.sort(function(a,b){
                        return a.offsetHeight-b.offsetHeight;
                    })
                    arr[0].appendChild(oLi);
            }
    
            for(var i=0;i<10;i++){
                creatEle();
            }
    
            window.onscroll=function(){
                var st=document.documentElement.scrollTop||document.body.scrollTop;
                var ch=document.documentElement.clientHeight;
    
                if(arr[0].offsetHeight <st+ch+200){
                    for(var i=0;i<10;i++){
                        creatEle();    
                    }
    
                }
            }
    
        </script>
    </body>
    </html>
  • 相关阅读:
    🍖名称空间与作用域
    🍖文件打开模式 "t"
    🍖函数参数
    【转】LINQ中的Aggregate语法
    【转】c#中string.trimstart() 和string.trimend() 的用法
    1094 和为k的连续区间(暴力)
    1095 Anigram单词
    1031 骨牌覆盖 (斐波拉契数列)
    最长公共子序列(模板 LCSL)
    1092 回文字符串(LCSL_DP)
  • 原文地址:https://www.cnblogs.com/jinsuo/p/6841067.html
Copyright © 2020-2023  润新知