zoukankan      html  css  js  c++  java
  • 瀑布流布局

    function page(n, s) {
                var ideaType = <%=ideaType%>;
                parent.window.document.getElementById("mainFrame").src = "${ctxf}/trend/idea/ideaList?&ideaType="+ ideaType+ "&pageNo=" + n + "&pageSize=" + s ;
         } 
         function down(obj,id){
            var pgcUrl = "<%=request.getHeader("Referer")%>";
            var href = "${ctxf}/trend/idea/download/"+encodeBase64(""+id)+"?pgcUrl="+pgcUrl;
            window.open(href);
        }
                var box = document.getElementById('box');
                var items = box.children;
                // 定义每一列之间的间隙 为10像素
                var gap = 20;
                    // 封装成一个函数
                function waterFall() {
                        var itemWidth = items[0].offsetWidth;
                        var columns = 5;
                        var arr = [];
                        for (var i = 0; i < items.length; i++) {      
                            if (i < columns) {
                                items[i].style.top = 0;
                                items[i].style.left = (itemWidth + gap) * i + 'px';
                                arr.push(items[i].offsetHeight);
                            } else {
                                var minHeight = arr[0];
                                var index = 0;
                                for (var j = 0; j < arr.length; j++) {
                                    if (minHeight > arr[j]) {
                                        minHeight = arr[j];
                                        index = j;
                                    }
                                }     
                                items[i].style.top = arr[index] + gap + 'px';
                                items[i].style.left = items[index].offsetLeft + 'px';
                                arr[index] = arr[index] + items[i].offsetHeight + gap;
                            }
                        }
                        var max = Math.max.apply(null, arr);
                        box.style.height = max  + 20 +  "px";
                        document.getElementById('page').style.display = "flex";
                        document.getElementById('ideaList').style.background = "#fff";
                    }
                    window.onload = function(){waterFall();}function page(n, s) {
                var ideaType = <%=ideaType%>;
                parent.window.document.getElementById("mainFrame").src = "${ctxf}/trend/idea/ideaList?&ideaType="+ ideaType+ "&pageNo=" + n + "&pageSize=" + s ;
         } 
         function down(obj,id){
            var pgcUrl = "<%=request.getHeader("Referer")%>";
            var href = "${ctxf}/trend/idea/download/"+encodeBase64(""+id)+"?pgcUrl="+pgcUrl;
            window.open(href);
        }
                var box = document.getElementById('box');
                var items = box.children;
                // 定义每一列之间的间隙 为10像素
                var gap = 20;
                    // 封装成一个函数
                function waterFall() {
                        var itemWidth = items[0].offsetWidth;
                        var columns = 5;
                        var arr = [];
                        for (var i = 0; i < items.length; i++) {      
                            if (i < columns) {
                                items[i].style.top = 0;
                                items[i].style.left = (itemWidth + gap) * i + 'px';
                                arr.push(items[i].offsetHeight);
                            } else {
                                var minHeight = arr[0];
                                var index = 0;
                                for (var j = 0; j < arr.length; j++) {
                                    if (minHeight > arr[j]) {
                                        minHeight = arr[j];
                                        index = j;
                                    }
                                }     
                                items[i].style.top = arr[index] + gap + 'px';
                                items[i].style.left = items[index].offsetLeft + 'px';
                                arr[index] = arr[index] + items[i].offsetHeight + gap;
                            }
                        }
                        var max = Math.max.apply(null, arr);
                        box.style.height = max  + 20 +  "px";
                        document.getElementById('page').style.display = "flex";
                        document.getElementById('ideaList').style.background = "#fff";
                    }
                    window.onload = function(){waterFall();}

     

  • 相关阅读:
    数据库迁移后,孤立账号解决办法
    一个很BT的汇总算法
    Working with tempdb in SQL Server 2005
    PHP 获取淘宝商品价格 函数
    Python 基础(一)环境搭建
    Python > 3.0导入库整理
    [转]ios输入框被键盘挡住的解决办法
    App更新说明的写作
    [转]Python 常用代码片段
    python BeautifulSoup 安装
  • 原文地址:https://www.cnblogs.com/zhoujingguoguo/p/11335762.html
Copyright © 2011-2022 走看看