论坛首页 Web前端技术论坛

Jquery简单瀑布流代码示例. 仿开心网,蘑菇街.

浏览 53761 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2012-07-19   最后修改:2012-07-19
  最近很多网站都采用瀑布流风格设计,感觉挺有个性的,比较合适做图片类型的网站,仿开心网做一个瀑布流示例。

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

演示地址:http://www.mn606.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 
QQ:35263107
演示地址:www.mm606.com
-->
<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>


  • 大小: 2.4 MB
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics