【发布时间】:2021-02-05 01:13:57
【问题描述】:
我正在尝试创建图像网格。它在我的屏幕上看起来不错,但我无法让它响应。当它超过 1000 像素宽度时,它开始连续拉伸。
当设备宽度变小时,我试图垂直推动每个 img div。
任何人都可以帮助我开始使我的图像网格响应。已经尝试让显示表格单元格并向左浮动但没有用。这是我的代码:
HTML
<div class="container">
<div class="d-flex">
<div class="img-wrapper-20">
<img src="https://informnutrition.com/wp-content/uploads/2019/03/Super-booster-Sheep-400x300.png" width="400px" height="300px" class="img-fluid img-thumbnail shadow" alt="Sheep 11">
<p class="galp">Some Text</p>
</div>
<div class="img-wrapper-20">
<img src="https://informnutrition.com/wp-content/uploads/2019/03/Super-booster-Sheep-400x300.png" width="400px" height="300px" class="img-fluid img-thumbnail shadow" alt="Sheep 11">
<p class="galp">Some Text</p>
</div>
<div class="img-wrapper-20">
<img src="https://informnutrition.com/wp-content/uploads/2019/03/Super-booster-Sheep-400x300.png" width="400px" height="300px" class="img-fluid img-thumbnail shadow" alt="Sheep 11">
<p class="galp">Some Text</p>
</div>
<div class="img-wrapper-20">
<img src="https://informnutrition.com/wp-content/uploads/2019/03/Super-booster-Sheep-400x300.png" width="400px" height="300px" class="img-fluid img-thumbnail shadow" alt="Sheep 11">
<p class="galp">Some Text</p>
</div>
<div class="img-wrapper-20">
<img src="https://informnutrition.com/wp-content/uploads/2019/03/Super-booster-Sheep-400x300.png" width="400px" height="300px" class="img-fluid img-thumbnail shadow" alt="Sheep 11">
<p class="galp">Some Text</p>
</div>
</div>
</div>
CSS
.container {
padding: 5rem 0rem;
}
.img-wrapper-20 {
width: 20%;
margin: 0rem 1.5rem 0rem 0rem;
}
.img-wrapper-20 img:hover {
transform: scale(1.08);
}
.galp {
margin-top: 20px;
text-align: center;
font-size: 20px;
font-weight: 700;
color: black;
}
@media screen and (max-width: 1000px) {
}
【问题讨论】:
标签: html css bootstrap-4 grid responsive