所以我想把我的文字放在图像下面,而不改变从行到列的弹性方向。
这是我的代码
.img-totm {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
.img-totm img {
height: 300px;
width: 400px;
padding: 20px 20px 10px 0px;
}
.img-totm h2 {}
<div class="img-totm">
<img src="images/img-berryblitz.jpg" alt="">
<h2>Fall Berry Blitz Tea</h2>
<img src="images/img-spiced-rum.jpg" alt="">
<img src="images/img-donut.jpg" alt="">
<img src="images/img-myrtle-ave.jpg" alt="">
<img src="images/img-bedford-bizarre.jpg" alt="">
</div>
.img-totm {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 8px;
}
.img-container {
display: flex;
flex-direction: column;
align-items: center;
}
.img-totm img {
display: block;
height: 200px;
width: 200px;
}
.img-totm h2 {
display: block;
font-size: 1rem;
}
<div class="img-totm">
<div class="img-container">
<img src="https://loremflickr.com/200/200/bee" alt="">
<h2>Fall Berry Blitz Tea</h2>
</div>
<img src="https://loremflickr.com/200/200/dog" alt="">
<img src="https://loremflickr.com/200/200/frog" alt="">
<img src="https://loremflickr.com/200/200/street" alt="">
<img src="https://loremflickr.com/200/200/cat" alt="">
</div>