使用 grid+媒体查询做响应式
<div class="wrapper">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
.wrapper {
display: grid;
grid-gap: 10px;
grid-template-rows: 50px 50px 50px;
}
.wrapper > div:nth-child(1) {
background-color: aquamarine;
}
.wrapper > div:nth-child(2) {
background-color: blanchedalmond;
}
.wrapper > div:nth-child(3) {
background-color: chartreuse;
}
@media (min-width: 1200px) {
.wrapper {
grid-template-columns: 30% 30% 30%;
}
}
@media (min-width: 768px) and (max-width: 1199px) {
.wrapper {
grid-template-columns: 45% 45%;
}
.wrapper > div:nth-child(3) {
grid-column: 1 / 3;
}
}
@media (min-width: 480px) and (max-width: 767px) {
.wrapper {
grid-template-columns: 100%;
}
}