深入学习深入学习js瀑布流布局瀑布流布局
本文实例为大家分享了js瀑布流布局学习资料,供大家参考,具体内容如下
特点:特点:等宽不等高。
实现方式:实现方式:Javascript/Jquery/CSS3多栏布局。
样例网站:花瓣网–>分类
一、一、JS实现瀑布流实现瀑布流
index.html:页面结构
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>瀑布流布局</title>
<link rel="stylesheet" href="styles/layout.css">
</head>
<body>
<div id="main">
<div class="box"><div class="pic"><img src="../waterFall/pic/0.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/1.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/2.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/3.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/4.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/5.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/6.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/7.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/8.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/9.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/10.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/11.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/12.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/13.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/14.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/15.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/16.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/17.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/18.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/19.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/20.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/21.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/22.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/23.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/24.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/25.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/26.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/27.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/28.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/29.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/30.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/31.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/32.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/33.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/34.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/35.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/36.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/37.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/38.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/39.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/40.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/41.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/42.jpg" alt=""></div></div>
<div class="box"><div class="pic"><img src="../waterFall/pic/43.jpg" alt=""></div></div>
</div>
<script src="scripts/waterfall.js"></script>
</body>
</html>
layout.css:页面元素样式
*{
pdding:0;
margin:0;
}