• Jquery简单瀑布流代码示例


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

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

    <!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> 
  • 相关阅读:
    RTThread | 启动下一代RTOS演化
    开发者应该开始学习C++吗?
    用googleperftool分析程序的内存/CPU使用
    看书看累了,可以换看技术视频也是一种学习的方式
    分享:nginx virtuanenv django1.4 应用简单部署
    分享:不同编程语言之间转换的项目矩阵
    【EDUPEPN8508GS黄金版】EDUP EPN8508GS黄金版 迷你USB无线网卡【行情 报价 价格 评测】
    分享:20 本优秀的 Python 电子书
    说说设计模式~工厂方法模式(Factory Method)
    说说设计模式~简单工厂模式(Factory)
  • 原文地址:https://www.cnblogs.com/elves/p/3630177.html
Copyright © 2020-2023  润新知