首页 > Web开发 > 详细

Jquery简单瀑布流代码示例

时间:2014-03-28 15:39:45      阅读:558      评论:0      收藏:0      [点我收藏+]

最近很多网站都采用瀑布流风格设计,感觉挺有个性的,比较合适做图片类型的网站,没事仿开心网做一个瀑布流示例。 

需要用到Jquery,jquery.masonry.min.js 

bubuko.com,布布扣
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<meta name="description" content="美女图片 - WWW.MN606.COM" /> 
<title>Masonry 瀑布流效果 - 美女图片</title> 
<style type="text/css"> 
body{background:#eee;font-size:12px;font-family:"宋体";color:#333p;} 
body,html,p,ul,li,dl,dt,dd,ol,h1,h2,h3,h4,h5{margin:0;padding:0;} 
ul li{list-style:none;} 
a{text-decoration: none;background-color: none} 
a:hover{text-decoration: none;} 
#page{ width:960px;  margin:0 auto; } 
#main{background:#FFF;height: 590px; float:left; width:960px;} 
.item{  border:1px solid #EEE;float: left;display: inline;padding: 10px;margin: 10px 0px 0 14px;position: relative;} 
.item img{border: none;} 
</style> 
</head> 
<!--  
《瀑布流效果》 
作者:Swiing 

--> 
<body> 
<div id="page"> 
  <div id="main"> 
    <div class="item"> 
      <a href="http://www.mn606.com/"> 
      <img src="http://image.mn606.com/images/2012/07/18/200_200/2012071820573960309.jpg"   /></a> 
      </div> 
    <div class="item"> 
      <a href="http://www.mn606.com/"> 
      <img src="http://image.mn606.com/images/2012/07/17/200_200/2012071701021504380.jpg"   /></a> 
    </div> 
      <div class="item"> 
      <a href="http://www.mn606.com/"> 
      <img src="http://image.mn606.com/images/2012/07/11/200_200/2012071100572176412.jpg"  /></a> 
    </div> 
    <div class="item"> 
      <a href="http://www.mn606.com/"> 
      <img src="http://image.mn606.com/images/2012/07/18/200_200/2012071820231163974.jpg"   /></a> 
    </div> 
    <div class="item"> 
      <a href="http://www.mn606.com/"> 
      <img src="http://image.mn606.com/images/2012/07/17/200_200/2012071701004194456.jpg"   /></a> 
    </div> 
   
     <div class="item"> 
      <a href="http://www.mn606.com/"> 
      <img src="http://image.mn606.com/images/2012/07/18/200_200/2012071820190205402.jpg"  /></a> 
    </div> 
     <div class="item"> 
      <a href="http://www.mn606.com/"> 
      <img src="http://image.mn606.com/images/2012/07/11/200_200/2012071100572176412.jpg"  /></a> 
    </div> 
    <div class="item"> 
      <a href="http://www.mn606.com/"> 
      <img src="http://image.mn606.com/images/2012/07/18/200_200/2012071820573960309.jpg"   /></a> 
    </div> 
    <div class="item"> 
      <a href="http://www.mn606.com/"> 
      <img src="http://image.mn606.com/images/2012/07/18/200_200/2012071820501119382.jpg"   /></a> 
    </div> 
    <div class="item"> 
      <a href="http://www.mn606.com/"> 
      <img src="http://image.mn606.com/images/2012/07/17/200_200/2012071701021504380.jpg"   /></a> 
    </div> 
    <div class="item"> 
      <a href="http://www.mn606.com/"> 
      <img src="http://image.mn606.com/images/2012/07/18/200_200/2012071820231163974.jpg"   /></a> 
    </div> 
    <div class="item"> 
      <a href="http://www.mn606.com/"> 
      <img src="http://image.mn606.com/images/2012/07/17/200_200/2012071701004194456.jpg"   /></a> 
    </div> 
    <div class="item"> 
       <a href="http://www.mn606.com/"> 
      <img src="http://image.mn606.com/images/2012/07/18/200_200/2012071820501119382.jpg"   /></a> 
    </div> 
     <div class="item"> 
      <a href="http://www.mn606.com/"> 
      <img src="http://image.mn606.com/images/2012/07/18/200_200/2012071820190205402.jpg"  /></a> 
    </div> 
     <div class="item"> 
      <a href="http://www.mn606.com/"> 
      <img src="http://image.mn606.com/images/2012/07/11/200_200/2012071100572176412.jpg"  /></a> 
    </div> 
    <div class="item"> 
      <a href="http://www.mn606.com/"> 
      <img src="http://image.mn606.com/images/2012/07/18/200_200/2012071820573960309.jpg"   /></a> 
      </div> 
    <div class="item"> 
      <a href="http://www.mn606.com/"> 
      <img src="http://image.mn606.com/images/2012/07/17/200_200/2012071701021504380.jpg"   /></a> 
    </div> 
    <div class="item"> 
      <a href="http://www.mn606.com/"> 
      <img src="http://image.mn606.com/images/2012/07/18/200_200/2012071820231163974.jpg"   /></a> 
    </div> 
    <div class="item"> 
      <a href="http://www.mn606.com/"> 
      <img src="http://image.mn606.com/images/2012/07/17/200_200/2012071701004194456.jpg"   /></a> 
    </div> 
    <div class="item"> 
       <a href="http://www.mn606.com/"> 
      <img src="http://image.mn606.com/images/2012/07/18/200_200/2012071820501119382.jpg"   /></a> 
    </div> 
     <div class="item"> 
      <a href="http://www.mn606.com/"> 
      <img src="http://image.mn606.com/images/2012/07/18/200_200/2012071820190205402.jpg"  /></a> 
    </div> 
  </div> 
</div> 
</body> 
<script src="js/jquery-1.7.1.min.js"></script> 
<script src="js/jquery.masonry.min.js"></script> 
<script> 
  $(function(){ 
    var $container = $(#main); 
    $container.imagesLoaded( function(){ 
      $container.masonry({ 
        itemSelector : .item 
      }); 
    }); 
  }); 
</script> 
</html> 
bubuko.com,布布扣

Jquery简单瀑布流代码示例,布布扣,bubuko.com

Jquery简单瀑布流代码示例

原文:http://www.cnblogs.com/elves/p/3630177.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!