on-internet
← Community

Width of flex container is behaving differently in 2 cases

Stack Overflow ·

In my first case there is a gallery which is declared a flex container. Its width grows as you increase the width of the viewport. <div class="gallery"> <img src="1.jpg"> <img src="2.jpg"> <img src="3.jpg"> <img src="4.jpg"> <img src="5.jpg"> <img src="6.jpg"> <img src="7.jpg"> <img src="8.jpg"> <img src="9.jpg"> </div> CSS for the above html .gallery { display: flex; flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; gap: 16px; max-width: 1400px; margin: 0 auto; padding: 20px 10px; } .gallery img { width: 100%; max-width: 350px; height: 300px; object-fit: cove

Comments

Sign in or sign up to comment and upvote.

No comments yet.