多列实现瀑布流的案例

瀑布流式布局。

是比较流行的一种网站页面布局,视觉表现为参差不齐的多栏布局

首先上结果图,看是否会是答案,一见钟情呢

![在这里插入图片描述](https://img-blog.csdnimg.cn/2020012100在这里插入图片描述

话不多说,确认过眼神,上代码是真爱啦

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		*{
			margin:0;
			padding:0;
			box-sizing: border-box;
		}
		body{
			background:#352323 url(img/a.png);
		}
		img{
			display:block;
		}
		section{
			max-width:95%;	
			margin:0 auto;
			overflow:hidden;
			column-count: 5;	
			column-gap:0;
			column-fill: auto;
		}
		figure{
			border:2px solid pink;
			margin:0 5px 10px;
			break-inside: avoid;
			padding:5px;
		/* 	font-variant:small-caps */
		}
		figure img{
			width:100%;
		}
		figcaption{
			padding:10px 0;
			text-align:center;
			font-weight:900;
			color:#a77869;
		}
		dialog{
			width:300px; height:400px; background:yellow; border:2px solid white;
			}
	</style>
</head>
<body>

	<section>
    
		<figure>
			<img src="img/1.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/2.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/3.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/4.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/5.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/6.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/7.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/8.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/9.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/10.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/11.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/12.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/13.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/14.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/15.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/16.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/17.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/18.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/19.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/20.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/21.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/22.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/23.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/24.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/25.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/26.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/27.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/28.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/29.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/30.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/31.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/32.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/33.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/34.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/35.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/36.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/37.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/38.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/39.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/40.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/41.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/42.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/43.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/44.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/45.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/46.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/47.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/48.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/49.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
		<figure>
			<img src="img/50.jpg" alt="">
			<figcaption>往后余生,风雪是你</figcaption>
		</figure>
	</section>
</body>
</html>

多列实现瀑布流可以会出现的bug

出现的bug:
1bug:

在这里插入图片描述

解决方法:给中断的元素添加:break-inside: avoid;
Break-inside属性详解:https://developer.mozilla.org/zh-CN/docs/Web/CSS/break-inside

2bug:

column-fill: 属性的必要性 : 每列高度统一的问题

3bug:

如果多列里面没有“容器标签”直接是img图片的情况下。图片的宽度设置为100% (为列宽的100%);

如果想要了解有关瀑布流的相关知识,请查看上一篇哦,请记得回头看哦

发布了36 篇原创文章 · 获赞 18 · 访问量 844

猜你喜欢

转载自blog.csdn.net/lff18277233091/article/details/104057551
今日推荐