I am currently exploring how to implement this layout using Flexbox. So far, I have only managed to come up with the following code snippet:
https://i.sstatic.net/mKVlu.jpg
Is there a way to achieve this purely through CSS without altering the HTML structure, considering it is generated using a PHP foreach loop?
Would utilizing CSS grid be beneficial in this scenario?
.grid {
display: flex;
justify-content: start;
flex-wrap: wrap;
}
.photo {
position: relative;
flex: 0 0 calc(25% - 20px);
margin: 10px;
align-self: flex-start;
overflow: hidden;
background: black;
}
.photo:after {
content: "";
display: block;
padding-top: 100%;
}
.large {
flex: 0 0 calc(50% - 20px);
}
<div class="grid">
<div class="photo large"></div>
<div class="photo"></div>
<div class="photo"></div>
<div class="photo"></div>
<div class="photo"></div>
</div>