首页 > 代码库 > jq瀑布流代码

jq瀑布流代码

<style>
#zh{ position:fixed; width:100%; height:100%; background:url(images/bgblack.png); top:0; left:0; z-index:99999; text-align:center;}
#zh img{ margin-top:20%;}
.list_bg{padding-top: 20px;}
.list{width: 1000px;height: auto;padding-bottom: 10px;margin-bottom: 10px;position: relative;}
.list_postion{height: 60px;line-height:60px;background-color:#FAFAFA;}
.line{height:1px;width:100%;clear:both;background:#FFF;border-top:1px solid #E0E0E0;margin-top:20px !important;}
.list_postion a{border: 1px solid #DDD;border-radius: 2px;font-size:12px;margin-left:20px;background:#F2F2F2;padding:9px 15px 9px 15px;}
.list_img{width: 100%;margin-top:20px;position: relative;min-height:800px; visibility:hidden;}
.list_img li{width: 236px;height: auto;overflow: hidden;position: absolute;left:25%;top:0;-webkit-transition: opacity .4s ease-in-out;-moz-transition: opacity .4s ease-in-out;-o-transition: opacity .4s ease-in-out;box-shadow:0px 1px 3px rgba(0,0,0,0.3);background-color:#fff;}
.list_img li a{display:block;}
.list_img li a img{margin:15px 15px 0px 15px;}
.list_img li a img:hover{filter:alpha(opacity=50);-moz-opacity:0.5;-khtml-opacity: 0.5;opacity: 0.5;}
.list_img li .title,.list_img li .description{clear: both;padding: 10px 0;font-size: 12px;color:#999;display: block;padding: 0 16px;margin: 10px 0;line-height: 1.35em;overflow: hidden;word-wrap: break-word}
.list_img li .title{ color:#333; font-family:"微软雅黑"; font-size:12px; font-weight:bolder;}
.list_img li .bottom{background: #FAFAFA;color: #999;border-top: 1px solid #F2F2F2;background: #FAFAFA;position: relative;}
.list_img li .bottom a{color: #39F}
.list_img li .bottom .text{height: auto;padding: 8px 15px 8px 15px;line-height: 1.5}
.list_img li .bottom .text .inner{font-size:12px;height: auto;overflow: hidden}
.kw{ background-color:#fff !important; }
.kw .inner{ color:#39f; text-align:right;}
</style>
    <div class="list">
        <ul class="list_img">
            <li>
                <a href="#" target="_blank"><img src="http://file.newsccn.com/images/2014/0504/20140504015406825.jpg" width="206" alt="上海一老式居民楼因煤气爆炸倒塌 已致2死4伤"></a>
                <p class="title">上海一老式居民楼因煤气爆炸倒塌 已致2死4伤</p>
                <div class="convo attribution clearfix bottom">
                    <div class="text">
                        <div class="inner">5月4日5时许,上海市新港路一老式居民楼因煤气爆炸发生倒塌。</div>
                    </div>
                </div>
                <div class="convo attribution clearfix bottom kw">
                    <div class="text">
                        <div class="inner">
                            <a href="#" style="display:inline" target="_blank">立交桥</a> / <a href="#" style="display:inline" target="_blank">火灾</a> / <a href="#" style="display:inline" target="_blank">桥梁坍塌</a>
                        </div>
                    </div>
                </div>
            </li>
            <li>
                <a href="#" target="_blank"><img src="http://file.newsccn.com/images/2014/0505/20140505102341915.jpg" width="206" alt="广东高州在建桥梁坍塌已致死11人"></a>
                <p class="title">广东高州在建桥梁坍塌已致死11人</p>
                <div class="convo attribution clearfix bottom">
                    <div class="text">
                        <div class="inner">广东一座在建石拱桥3日发生坍塌事故,已致死11人。</div>
                    </div>
                </div>
                <div class="convo attribution clearfix bottom kw">
                    <div class="text">
                        <div class="inner">
                            <a href="#" style="display:inline" target="_blank">立交桥</a> / <a href="#" style="display:inline" target="_blank">火灾</a> / <a href="#" style="display:inline" target="_blank">桥梁坍塌</a>
                        </div>
                    </div>
                </div>
            </li>
            <li>
                <a href="#" target="_blank"><img src="http://file.newsccn.com/images/2014/0506/20140506101618921.jpg" width="206" alt="建筑物水中倒影 城市之美尽在此"></a>
                <p class="title">建筑物水中倒影 城市之美尽在此</p>
                <div class="convo attribution clearfix bottom">
                    <div class="text">
                        <div class="inner">建筑物本身与它在水中的倒影交相辉映,带给人一种不一样的观赏感受。</div>
                    </div>
                </div>
                <div class="convo attribution clearfix bottom kw">
                    <div class="text">
                        <div class="inner">
                            <a href="#" style="display:inline" target="_blank">立交桥</a> / <a href="#" style="display:inline" target="_blank">火灾</a> / <a href="#" style="display:inline" target="_blank">桥梁坍塌</a>
                        </div>
                    </div>
                </div>
            </li>
            <li>
                <a href="#" target="_blank"><img src="http://file.newsccn.com/images/2014/0506/20140506095838222.jpg" width="206" alt="南宁城中村现大规模“”"></a>
                <p class="title">南宁城中村现大规模“”</p>
                <div class="convo attribution clearfix bottom">
                    <div class="text">
                        <div class="inner">广西南宁,城中村大规模“亲嘴楼”惊现大量空中“棚户区”。</div>
                    </div>
                </div>
                <div class="convo attribution clearfix bottom kw">
                    <div class="text">
                        <div class="inner">
                            <a href="#" style="display:inline" target="_blank">立交桥</a> / <a href="#" style="display:inline" target="_blank">火灾</a> / <a href="#" style="display:inline" target="_blank">桥梁坍塌</a>
                        </div>
                    </div>
                </div>
            </li>
            <li>
                <a href="#" target="_blank"><img src="http://file.newsccn.com/images/2014/0506/20140506023718582.jpg" width="206" alt="英国52岁男子5年花500万改建复古老房"></a>
                <p class="title">英国52岁男子5年花500万改建复古老房</p>
                <div class="convo attribution clearfix bottom">
                    <div class="text">
                        <div class="inner">英国男子将他的都铎老屋改造成一座具有16世纪风格的房子。</div>
                    </div>
                </div>
                <div class="convo attribution clearfix bottom kw">
                    <div class="text">
                        <div class="inner">
                            <a href="#" style="display:inline" target="_blank">立交桥</a> / <a href="#" style="display:inline" target="_blank">火灾</a> / <a href="#" style="display:inline" target="_blank">桥梁坍塌</a>
                        </div>
                    </div>
                </div>
            </li>
            <li>
                <a href="#" target="_blank"><img src="http://file.newsccn.com/images/2014/0506/20140506022322150.jpg" width="206" alt="重庆四川美术学院修建城堡校门"></a>
                <p class="title">重庆四川美术学院修建城堡校门</p>
                <div class="convo attribution clearfix bottom">
                    <div class="text">
                        <div class="inner">重庆四川美术学院正在修建的酷似城堡的校门惹争议。</div>
                    </div>
                </div>
                <div class="convo attribution clearfix bottom kw">
                    <div class="text">
                        <div class="inner">
                            <a href="#" style="display:inline" target="_blank">立交桥</a> / <a href="#" style="display:inline" target="_blank">火灾</a> / <a href="#" style="display:inline" target="_blank">桥梁坍塌</a>
                        </div>
                    </div>
                </div>
            </li>
            <li>
                <a href="#" target="_blank"><img src="http://file.newsccn.com/images/2014/0506/20140506040709905.jpg" width="206" alt="上海倒楼之后棚户区不忍直视"></a>
                <p class="title">上海倒楼之后棚户区不忍直视</p>
                <div class="convo attribution clearfix bottom">
                    <div class="text">
                        <div class="inner">上海市老式居民楼倒了,随之浮出水面的是12年都没有拆掉的棚户区。</div>
                    </div>
                </div>
                <div class="convo attribution clearfix bottom kw">
                    <div class="text">
                        <div class="inner">
                            <a href="#" style="display:inline" target="_blank">立交桥</a> / <a href="#" style="display:inline" target="_blank">火灾</a> / <a href="#" style="display:inline" target="_blank">桥梁坍塌</a>
                        </div>
                    </div>
                </div>
            </li>
            <li>
                <a href="#" target="_blank"><img src="http://file.newsccn.com/images/2014/0506/20140506043229932.jpg" width="206" alt="湖北宜昌4s店楼顶层成“停车场” 停了50余辆车"></a>
                <p class="title">湖北宜昌4s店楼顶层成“停车场” 停了50余辆车</p>
                <div class="convo attribution clearfix bottom">
                    <div class="text">
                        <div class="inner">5月4日,在湖北宜昌港窑路附近,一家小轿车4S店楼顶停了50余辆车。</div>
                    </div>
                </div>
                <div class="convo attribution clearfix bottom kw">
                    <div class="text">
                        <div class="inner">
                            <a href="#" style="display:inline" target="_blank">立交桥</a> / <a href="#" style="display:inline" target="_blank">火灾</a> / <a href="#" style="display:inline" target="_blank">桥梁坍塌</a>
                        </div>
                    </div>
                </div>
            </li>
            <li>
                <a href="#" target="_blank"><img src="http://file.newsccn.com/images/2014/0507/20140507093543735.jpg" width="206" alt="加拿大一派对引2000人狂欢致豪宅被毁"></a>
                <p class="title">加拿大一派对引2000人狂欢致豪宅被毁</p>
                <div class="convo attribution clearfix bottom">
                    <div class="text">
                        <div class="inner">加拿大一豪宅举办派对,结果豪宅被2000多名狂欢者疯狂破坏。</div>
                    </div>
                </div>
                <div class="convo attribution clearfix bottom kw">
                    <div class="text">
                        <div class="inner">
                            <a href="#" style="display:inline" target="_blank">立交桥</a> / <a href="#" style="display:inline" target="_blank">火灾</a> / <a href="#" style="display:inline" target="_blank">桥梁坍塌</a>
                        </div>
                    </div>
                </div>
            </li>
            <li>
                <a href="#" target="_blank"><img src="http://file.newsccn.com/images/2014/0507/20140507101139869.jpg" width="206" alt="南京夫子庙拆违建 户主持刀抗拒"></a>
                <p class="title">南京夫子庙拆违建 户主持刀抗拒</p>
                <div class="convo attribution clearfix bottom">
                    <div class="text">
                        <div class="inner">城管欲拆除小区搭盖的阳光房,男子手持菜刀与警方对峙。</div>
                    </div>
                </div>
                <div class="convo attribution clearfix bottom kw">
                    <div class="text">
                        <div class="inner">
                            <a href="#" style="display:inline" target="_blank">立交桥</a> / <a href="#" style="display:inline" target="_blank">火灾</a> / <a href="#" style="display:inline" target="_blank">桥梁坍塌</a>
                        </div>
                    </div>
                </div>
            </li>
        </ul>
    </div>
<script type="text/javascript">
var margin = 18;
var marginT = 18;
var li = $(".list_img>li");
var li_w = li[0].offsetWidth + margin;
var speed = 1000;
function sortMin(arr) {
    var a = b = 0;
    a = Math.min.apply(null, arr);
    for (var i = 0; i < arr.length; i++) {
        if (a == arr[i]) {
            b = i;
        }
    }
    return a + "|" + b;
}
function ulh(arr) {
    var a = sortMin(arr).split("|");
    var hei = Number(a[0]) + li.eq(a[1]).height() + 50;
    $(".list_img").height(hei);
}
function pbl() {
    $("#zh").remove();
    $(".list_img").css("visibility", "visible");
    var $maxWidth = li.parent("ul").width();
    var $l_num = Math.round(li.parent("ul").width() / li_w);
    var l_h_arr = new Array();
    li.each(function(i) {
        var $height = $(this).height() + marginT;
        if (i < $l_num) {
            var $top = 0;
            var $index = $(this).index();
            l_h_arr[i] = $height;
        } else {
            var Arr = sortMin(l_h_arr).split("|");
            $index = Arr[1];
            $top = Arr[0];
            l_h_arr[$index] += $height;
        }
        var $left = li_w * $index;
        $(this).animate({left:$left},slow).delay(100).animate({top:$top}, {easing:"swing",duration:speed});
    });
    ulh(l_h_arr);
}
window.onload = function() {pbl();};
window.onresize = function() {pbl();};
</script>

需要分页,没有自动加载效果。