【发布时间】:2018-04-28 09:42:26
【问题描述】:
我正在尝试制作小网格图像。在台式机上,我希望每列 3 张图像,而在移动设备上,我希望每列 2 张图像。我这样做没有问题。当我将页面大小缩小到移动设备大小时,问题就开始了。图像的顺序正确,但它们不会缩小,它们保持原来的大小,右边的那个超出了网格(你看不到它的一半)。我试过 max-width:100%, width:100% 等。没有用。
.sponsors1 {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
}
@media(max-width:768px) {
.sponsors1 {
grid-template-columns: 1fr 1fr;
justify-self: center;
grid-gap: 8px;
margin-top: 10px;
margin-bottom: 20px;
align-items: center;
overflow:
}
.img1 {
justify-self: center;
}
.img2 {
justify-self: center;
}
.img3 {
justify-self: center;
}
}
<div class="sponsors1">
<a href="#/" class="img1"><img src="images/#.png" alt=""></a>
<a href="#" class="img2"><img src="images/#.jpg" alt=""></a>
<a href="#" class="img3"><img src="images/#.png" alt=""></a>
</div>
【问题讨论】:
标签: css responsive-design grid css-grid