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();}

     

  • 相关阅读:
    [git]git的简单配置使用 (将你的代码上传到Github)
    学习进度报告【第六周】
    [错误解决]SpringMVC接收对象 中文乱码问题解决
    [架构]myeclipse配置SpringMVC 以及简单应用 教程
    [机器学习]AttributeError: module 'tensorflow' has no attribute 'ConfigProto' 报错解决方法
    [机器学习]RuntimeError: The Session graph is empty. Add operations to the graph before calling run(). 报错解决方法
    [python]机器学习 k-mean 聚类分析
    学习进度报告【第五周】
    学习进度报告【第四周】
    unity3d优化总结篇
  • 原文地址:https://www.cnblogs.com/zhoujingguoguo/p/11335762.html
Copyright © 2011-2022 走看看