代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
.waterfall{
column-count: 3;
column-gap: 0;
}
.item{
box-sizing: border-box;
break-inside: avoid;
padding: 10px;
}
.item-content{
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 10px;
height: auto;
font-size: 20px;
color: #686868;
box-sizing: border-box;
border: 1px solid #ccc;
}
/* 图片自适应 */
/* img {
width: auto !important;
height: auto !important;
width: 100% !important;
max-height: 100% !important;
} */
</style>
<body>
<div class="waterfall">
<div class="item">
<div class="item-content">
三月到大理赏樱花不远不近
<img src="https://img1.baidu.com/it/u=3293231005,2758635617&fm=26&fmt=auto" alt="" style="width: 200px;height: 100px;">
</div>
</div>
<div class="item">
<div class="item-content">
三月到大理赏樱花不远不近,才是最好的距离余生,请带上自己的阳光回忆,在部队那些日子被遗忘的花儿春光
<img src="https://img2.baidu.com/it/u=3230608530,902431355&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500" alt="" style="width: 200px;height: 100px;">
</div>
</div>
<div class="item">
<div class="item-content">
三月到大理赏樱花不远不近,才是最好的距离余生,请带上自己的阳光回忆
<img src="https://img1.baidu.com/it/u=1265359652,2602599314&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=708" alt="" style="width: 100px;height: 100px;">
</div>
</div>
<div class="item">
<div class="item-content">
三月到大理赏樱花不远不近,才是最好的距离余生,请带上自己的阳光回忆
<img src="https://img2.baidu.com/it/u=672776529,4061746392&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=889" alt="" style="width: 400px;height: 100px;">
</div>
</div>
<div class="item">
<div class="item-content">
三月到大理赏樱三月到大理赏樱花不远不近,才是最好的距离余生,请带上自己的阳光回忆三月到大理赏樱花不远不近,才是最好的距离余生,请带上自己的阳光回忆花不远不近,才是最好的距离余生,请带上自己的阳光回忆
<img src="https://img2.baidu.com/it/u=121521759,2505802225&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500" alt="" style="width: 200px;height: 100px;">
</div>
</div>
<div class="item">
<div class="item-content">
三月到大理赏樱花不远不近,才是最好的距离三月到大理赏樱花不远不近,才是最好的距离余生,请带上自己的阳光回忆三月到大理赏樱花不远不近,才是最好的距离余生,请带上自己的阳光回忆三月到大理赏樱花不远不近,才是最好的距离余生,请带上自己的阳光回忆余生,请带上自己的阳光回忆
<img src="https://img1.baidu.com/it/u=2414851883,3281230339&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500" alt="" style="width: 200px;height: 300px;">
</div>
</div>
<div class="item">
<div class="item-content">
三月到大理赏樱花不远不近,才是最好的距离余生,请带上自己的阳光回忆三月到大理赏樱花不远不近,才是最好的距离余生,请带上自己的阳光回忆三月到大理赏樱花不远不近,才是最好的距离余生,请带上自己的阳光回忆三月到大理赏樱花不远不近,才是最好的距离余生,请带上自己的阳光回忆
<img src="https://img2.baidu.com/it/u=768172750,521301536&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500" alt="" style="width: 200px;height: 250px;">
</div>
</div>
</div>
</body>
</html>
效果图