原文:https://www.jq22.com/webqd6733
<div class="container">
<div class="box">
<img src="http://www.jq22.com/img/cs/500x500-1.png" alt="">
<h2>你好啊!1</h2>
<p>hahahahah</p>
</div>
<div class="box">
<img src="http://www.jq22.com/img/cs/500x300-1.png" alt="">
<h2>你好啊!6</h2>
<p>hahahahah</p>
</div>
<div class="box">
<img src="http://www.jq22.com/img/cs/300x500-1.png" alt="">
<h2>你好啊!2</h2>
<p>hahahahah</p>
</div>
<div class="box">
<img src="http://www.jq22.com/img/cs/500x500-1.png" alt="">
<h2>你好啊!1</h2>
<p>hahahahah</p>
</div>
<div class="box">
<img src="http://www.jq22.com/img/cs/500x300-1.png" alt="">
<h2>你好啊!6</h2>
<p>hahahahah</p>
</div>
<div class="box">
<img src="http://www.jq22.com/img/cs/300x500-1.png" alt="">
<h2>你好啊!2</h2>
<p>hahahahah</p>
</div>
<div class="box">
<img src="http://www.jq22.com/img/cs/500x500-1.png" alt="">
<h2>你好啊!1</h2>
<p>hahahahah</p>
</div>
<div class="box">
<img src="http://www.jq22.com/img/cs/500x300-1.png" alt="">
<h2>你好啊!6</h2>
<p>hahahahah</p>
</div>
<div class="box">
<img src="http://www.jq22.com/img/cs/300x500-1.png" alt="">
<h2>你好啊!2</h2>
<p>hahahahah</p>
</div>
</div>
.body {
margin:0;
padding:0;
background:#333;
}
.container {
width:1200px;
margin:20px auto;
columns:4;
column-gap:40px;
}
.container .box {
width:100%;
margin:0 0 20px;
padding:10px;
background:#fff;
overflow:hidden;
break-inside:avoid;
}
.container .box img {
max-width:100%;
}
@media(max-width:1200px) {
.container {
columns:3;
width:calc(100% - 40px);
box-sizing:border-box;
padding:20px 20px 20px 0;
}
}@media(max-width:768px) {
.container {
columns:2;
}
}@media(max-width:480px) {
.container {
columns:1;
}
}