• 瀑布流


    <html>
    <head>
        <meta charset="utf-8">
        <title>瀑布流</title>
        <style type="text/css">
            #main {
                positionrelative;
            }
            .box {
                padding5px;
                floatleft;
            }
            .pic {
                heightauto;
                padding5px;
                border1px solid gray;
                border-radius5px;
            }
                .pic img {
                    width200px;
                }
        </style>
        <script type="text/javascript" src="jquery-1.9.1.js"></script>
        <script>
            window.onload = function () {
                waterfall();
            }
            window.onscroll = function () {
                var lastBox = $("#main>div").last();
                var lastH = lastBox.offset().top + Math.floor(lastBox.outerHeight());
                var soc = $(window).scrollTop();
                var docHeight = $(window).height();
                if (lastH - docHeight - soc < 50) {
                    console.log("加载" + (lastH - docHeight - soc));
                    var jsonData = {
                        "data": [
                            { "src""images/02.jpg" }, { "src""images/03.jpg" },
                            { "src""images/01.jpg" }, { "src""images/02.jpg" },
                            { "src""images/03.jpg" }, { "src""images/04.jpg" },
                            { "src""images/04.jpg" }, { "src""images/02.jpg" },
                            { "src""images/05.jpg" }, { "src""images/04.jpg" },
                        ]
                    };
                    $(jsonData.data).each(function (i, item) {
                        var oBox = $("<div>").addClass("box").appendTo($("#main"));
                        var pic = $("<div>").addClass("pic").appendTo(oBox);
                        $("<img>").attr("src", item.src).appendTo(pic);
                    });
                    waterfall();
                }
            }
            function waterfall() {
                var $box = $("#main>div");
                var w = $box.eq(0).outerWidth();
                var cols = Math.floor($(window).width() / w);
                $("#main").width(w * cols).css("margin""0 auto");
                var hArr = [];
                $box.each(function (i, item) {
                    var h = $box.eq(i).outerHeight();
                    if (i < cols) {
                        hArr[i] = h;
                    } else {
                        var minH = Math.min.apply(null, hArr);
                        var minInx = $.inArray(minH, hArr);
                        // console.log(minH + '--' + minInx);
                        $(item).css({
                            "position""absolute",
                            "top": minH + "px",
                            "left": minInx * w + "px"
                        });
                        hArr[minInx] += $box.eq(i).outerHeight();
                    }
                });
            }
        </script>
    </head>
    <body>
        <div id="main">
            <div class="box">
                <div class="pic">
                    <img src="images/01.jpg" />
                </div>
            </div>
        </div>
    </body>
    </html>




  • 相关阅读:
    Ubuntu 8.04安设nVidia新版表现驱动
    特性化设置你的linux环境
    Ubuntu 8.04 去失踪文泉驿的点阵字形的方法
    Fedora Nightlife项目 扶助较劲争论机的空闲
    Ubuntu显卡驱动不精确,进入黑屏的处置装备
    Linux中翻开带flash网页主动封锁的处理办法
    Firefox 3 Alpha 5
    Ubuntu 8.04无法正常关机成就处置惩罚
    Redhat Enterprise Linux 5.2 公布了
    KOffice 1.6.3
  • 原文地址:https://www.cnblogs.com/jzb-dev/p/4971981.html
Copyright © 2020-2023  润新知