I am struggling to align the child flexboxes within my parent flexbox in a single row, both vertically and horizontally centered. I want to add space between them using the gap property in CSS, but the images and embedded videos inside these child flexboxes don't stretch horizontally as intended.
.latest-news-format {
background-color: #8ebfa1;
display: flex;
justify-content: space-around;
align-items: stretch;
gap: 10px;
}
.latest-news-format div {
display: flex;
flex-direction: column;
align-items: center;
width: 30%;
max-height: 100%;
border: 1px solid black;
}
.latest-news-format div img {
/* max-width: 100%; */
object-fit: cover;
max-height: 80%;
max-width: 100%;
/* aspect-ratio: 16/9; */
}
.latest-news-format div p {
text-align: center;
/* This centers the text within each div */
margin-bottom: auto;
/* This pushes the text to the bottom of the div */
}
.latest-news-format div iframe {
/* object-fit: cover; */
flex-grow: 1;
flex-shrink: 1;
aspect-ratio: auto;
margin: auto;
}
<div style="max-width: 100%; height: 20%; background-color: bisque; display:flex; flex-wrap: wrap; align-content: space-evenly; margin: 20px 0px;">
<h2>
Latest News
</h2>
<br>
<div style="margin: 15px 15px;" class="latest-news-format">
<!--iKON news-->
<div>
<a href="https://www.soompi.com/article/1598908wpp/ikons-jinhwan-announces-military-enlistment-date-with-heartfelt-message" title="iKON Jinhwan Enlistment Announcement" target="_blank">
<img style="object-fit: contain; max-width: 100%;" src="https://picsum.photos/200/300.webp" alt="iKON group photo">
<p>
iKON Jinhwan Enlistment Announcement with Heartfelt Letter
</p>
</a>
</div>
<!--SEVENTEEN news-->
<div>
<a href="https://www.soompi.com/article/1648474wpp/seventeen-to-headline-lollapalooza-berlin-2024" title="SEVENTEEN Headline at Lollapalooza 2024" target="_blank">
<img src="https://picsum.photos/200/300.webp" alt="SEVENTEEN group photo">
<p>SEVENTEEN Perform At Lollapalooza Berlin</p>
</a>
</div>
<!--SEVENTEEN watch-->
<div>
<iframe src="https://youtu.be/4g6AC6mXShE?si=bxoYJBNyIaxXMNCp"></iframe>
<a href="https://youtu.be/4g6AC6mXShE?si=bxoYJBNyIaxXMNCp" title="Going SEVENTEEN EP.79" target="_blank">
<p>
Watch: Going SEVENTEEN New Episode 79 - Going Vol 2
</p>
</a>
</div>
<!--TAEYONG news-->
<div>
<a href="https://www.soompi.com/article/1649391wpp/ncts-taeyong-confirms-military-enlistment-date" title="Taeyong Enlistment Date" target="_blank">
<img src="https://picsum.photos/200/300.webp" alt="Taeyong picture" title="Taeyong Enlistment Date">
<p>
SM Confirms Taeyong Military Enlistment Date
</p>
</a>
</div>
</div>
</div>
My goal is to have all images/iframes (embedded videos) with equal width, fully stretched horizontally within their respective flexboxes, and equal height. And there should be a visible gap between the child flexboxes.