【Css】使用多列布局实现图片瀑布流
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
html, body {
height: 100%;
}
.box{
column-count: 3;
}
.box img{
width: 100%;
}
.box div{
border: 2px solid #00cc66;
padding: 5px;
margin-bottom: 10px;
/*禁止盒子内部折行*/
break-inside: avoid;
}
.box div p{
line-height: 30px;
text-align: center;
font-size: 14px;
}
</style>
</head>
<body>
<div class="box">
<div>
<img src="https://images.unsplash.com/photo-1651772522632-e6b3723e3e8e?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxleHBsb3JlLWZlZWR8MXx8fGVufDB8fHx8&auto=format&fit=crop&w=500&q=60" alt="">
<p>Browse premium related images on iStock | Save 20% with code UNSPLASH20</p>
</div>
<div>
<img src="https://images.unsplash.com/photo-1651742744859-402a6a830f68?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1170&q=80" alt="">
<p>Browse premium related images on iStock | Save 20% with code UNSPLASH20</p>
</div>
<div>
<img src="https://images.unsplash.com/photo-1651837023192-ddf9381a892a?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80" alt="">
<p>Browse premium related images on iStock | Save 20% with code UNSPLASH20</p>
</div>
<div>
<img src="https://images.unsplash.com/photo-1651634039471-9c9c7313fde6?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80" alt="">
<p>Browse premium related images on iStock | Save 20% with code UNSPLASH20</p>
</div>
<div>
<img src="https://images.unsplash.com/photo-1651837023192-ddf9381a892a?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80" alt="">
<p>Browse premium related images on iStock | Save 20% with code UNSPLASH20</p>
</div>
<div>
<img src="https://images.unsplash.com/photo-1651634039471-9c9c7313fde6?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80" alt="">
<p>Browse premium related images on iStock | Save 20% with code UNSPLASH20</p>
</div>
<div>
<img src="https://images.unsplash.com/photo-1651742744859-402a6a830f68?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1170&q=80" alt="">
<p>Browse premium related images on iStock | Save 20% with code UNSPLASH20</p>
</div>
<div>
<img src="https://images.unsplash.com/photo-1651634039471-9c9c7313fde6?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80" alt="">
<p>Browse premium related images on iStock | Save 20% with code UNSPLASH20</p>
</div>
<div>
<img src="https://images.unsplash.com/photo-1651837023192-ddf9381a892a?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80" alt="">
<p>Browse premium related images on iStock | Save 20% with code UNSPLASH20</p>
</div>
<div>
<img src="https://images.unsplash.com/photo-1651634039471-9c9c7313fde6?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80" alt="">
<p>Browse premium related images on iStock | Save 20% with code UNSPLASH20</p>
</div>
<div>
<img src="https://images.unsplash.com/photo-1651837023192-ddf9381a892a?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80" alt="">
<p>Browse premium related images on iStock | Save 20% with code UNSPLASH20</p>
</div>
<div>
<img src="https://images.unsplash.com/photo-1651742744859-402a6a830f68?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1170&q=80" alt="">
<p>Browse premium related images on iStock | Save 20% with code UNSPLASH20</p>
</div>
<div>
<img src="https://images.unsplash.com/photo-1651634039471-9c9c7313fde6?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80" alt="">
<p>Browse premium related images on iStock | Save 20% with code UNSPLASH20</p>
</div>
<div>
<img src="https://images.unsplash.com/photo-1651837023192-ddf9381a892a?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80" alt="">
<p>Browse premium related images on iStock | Save 20% with code UNSPLASH20</p>
</div>
<div>
<img src="https://images.unsplash.com/photo-1651634039471-9c9c7313fde6?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=387&q=80" alt="">
<p>Browse premium related images on iStock | Save 20% with code UNSPLASH20</p>
</div>
<div>
<img src="https://images.unsplash.com/photo-1651827185188-f80430dd9cd3?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxleHBsb3JlLWZlZWR8N3x8fGVufDB8fHx8&auto=format&fit=crop&w=500&q=60" alt="">
<p>Browse premium related images on iStock | Save 20% with code UNSPLASH20</p>
</div>
</div>
</body>
</html>
本文来自博客园,作者:木子欢儿,转载请注明原文链接:https://www.cnblogs.com/HGNET/p/16340245.html