转自 · · 1923 阅读

mui 图片实现瀑布流显示

瀑布流

原文链接:http://www.bcty365.com/content-146-5320-1.html


  1. <body style="background-color: #f3f3f3;"> 
  2.     <!-- 商品列表 --> 
  3.     <div class="twoRankedBox"> 
  4.         <ul class="BoxLeft"> 
  5.  
  6.         </ul> 
  7.  
  8.         <ul class="BoxRight"> 
  9.  
  10.         </ul> 
  11.     </div> 
  12. </body> 

  1. *{ 
  2.     padding:0px
  3.     margin:0px
  4.     list-stylenone
  5.     font-style:normal
  6.     font-familyarial
  7.     font-family: Microsoft YaHei,arial
  8. .twoRankedBox{ 
  9.     margin:6px 8px
  10.     overflowhidden
  11.     padding-bottom:25px
  12. .twoRankedBox ul{ 
  13.     width:49%
  14.     floatleft
  15. .twoRankedBox ul:last-child{ 
  16.     margin-left:2%
  17. .twoRankedBox ul li{ 
  18.     padding:5px
  19.     margin-bottom:6px
  20.     padding-bottom:8px
  21.     background-color#FFFFFF
  22. .twoRankedBox ul li p:first-child{ 
  23.     padding-top:0px
  24. .twoRankedBox ul li p{ 
  25.     padding-top:4px
  26. .product_picture img{ 
  27.     displayblock
  28.     width:100%
  29. .product_np{ 
  30.     overflowhidden
  31.     line-height:20px
  32. .product_np a{ 
  33.     displayblock
  34.     overflow:hidden
  35.     text-overflow:ellipsis; 
  36.     white-space:nowrap
  37. .product_np a:first-child{ 
  38.     font-size:0.9em
  39.     color:#58b7e3
  40.     width:65%
  41.     floatleft
  42. .product_np a:last-child{ 
  43.     font-size:0.8em
  44.     color:#f00
  45.     floatright
  46.     width:35%
  47.     text-alignright
  48. .product_ie{ 
  49.     font-size:0.8em
  50.     color:#777
  1. for(var i=0;i<json.data.length;i++){ 
  2.     var chtml = '<li><p class="product_picture"><img src="'+json.data[i].src+'"></p>' 
  3.             +'<p class="product_np"><a>'+json.data[i].name+'</a><a>¥'+json.data[i].price+'</a></p>' 
  4.             +'<p class="product_ie">'+json.data[i].details+'</p></li>' 
  5.  
  6.     if($('.BoxLeft').height() < $('.BoxRight').height()){ 
  7.         $('.BoxLeft').append(chtml); 
  8.     }else
  9.         $('.BoxRight').append(chtml); 
  10.     }