I'm in the process of creating a website. Within the content area, there are flex-boxes containing images. The number of images can vary (up to 5), and I need to calculate the width of each image to ensure they all fit.
Oddly enough, this works perfectly fine in FireFox, but not in Chrome or Yandex.
It seems like the images are not auto-fitting within the flex-box because the declared height is set to 400px
, causing the width: 100%
property to correspond to that 400px
height.
Below are the HTML and CSS sections:
HTML
<div class="article-images">
<img src="../images/newsImages/img_6_4.jpg" class="article-images-item" />
<img src="../images/newsImages/img_6_5.jpg" class="article-images-item" />
<img src="../images/newsImages/img_6_6.jpg" class="article-images-item" />
<img src="../images/newsImages/img_6_9.jpg" class="article-images-item" />
</div>
CSS
.article-images {
display: flex;
flex-direction: row;
justify-content: space-evenly;
gap: 20px;
width: 100%
}
.article-images-item {
width: 100%;
height: 400px;
object-fit: cover;
border-radius: 2px;
cursor: pointer
}
Expected output (as seen in FireFox):
https://i.sstatic.net/FczuN.png