瀑布流布局原理:
- 使用分栏布局
- 让每一个元素在所在的栏都设置width:100%
- 每个元素在加载的时候都会去找当前高度最小的那个一栏 依次进行排序
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
div {
column-count: 8;
column-rule: 1px solid red;
}
img {
width: 100%;
}
</style>
</head>
<body>
<div>
<img src="./img/1.jpg" alt="">
<img src="./img/2.png" alt="">
<img src="./img/3.png" alt="">
<img src="./img/4.png" alt="">
<img src="./img/5.jpg" alt="">
<img src="./img/6.png" alt="">
<img src="./img/7.jpg" alt="">
<img src="./img/8.png" alt="">
<img src="./img/9.png" alt="">
<img src="./img/10.png" alt="">
<img src="./img/11.png" alt="">
<img src="./img/12.png" alt="">
<img src="./img/13.png" alt="">
<img src="./img/14.jpg" alt="">
<img src="./img/15.jpg" alt="">
<img src="./img/16.jpg" alt="">
<img src="./img/17.jpg" alt="">
<img src="./img/18.jpg" alt="">
<img src="./img/19.jpg" alt="">
<img src="./img/20.jpg" alt="">
<img src="./img/21.jpg" alt="">
<img src="./img/22.jpg" alt="">
<img src="./img/23.jpg" alt="">
<img src="./img/15.jpg" alt="">
<img src="./img/16.jpg" alt="">
<img src="./img/17.jpg" alt="">
<img src="./img/18.jpg" alt="">
<img src="./img/19.jpg" alt="">
<img src="./img/20.jpg" alt="">
<img src="./img/21.jpg" alt="">
<img src="./img/22.jpg" alt="">
<img src="./img/23.jpg" alt="">
<img src="./img/22.jpg" alt="">
<img src="./img/23.jpg" alt="">
<img src="./img/17.jpg" alt="">
<img src="./img/18.jpg" alt="">
<img src="./img/17.jpg" alt="">
<img src="./img/18.jpg" alt="">
</div>
</body>
</html>