I have tried this with flexbox with negative bottom and positive top margins, but the children of a flexbox are harder to style than it seemed.
Is there a better way to achieve this effect?
Is Flexbox even the way to go here?
How could I achieve this with a good modern solution?
And how would you handle this responsive wise?
.broken-grid {
display: flex;
justify-content: center;
margin: 0 0 -30px -30px;
}
.broken-grid__item {
display: flex;
flex-direction: column;
margin-bottom: 30px;
padding-left: 30px;
}
.visual {
width: 25vw;
height: 100%;
margin-bottom: 30px;
}
.visual:nth-child(4n + 2) {
margin-bottom: -50px;
margin-top: 100px;
}
.visual:nth-child(4n + 3) {
margin-top: -50px;
margin-bottom: 100px;
}
<div class="broken-grid">
<div class="broken-grid__item">
<picture class="visual">
<source srcset="https://picsum.photos/700" type="image/webp">
<img src="https://picsum.photos/700" alt="">
</picture>
<picture class="visual">
<source srcset="https://picsum.photos/700" type="image/webp">
<img src="https://picsum.photos/700" alt="">
</picture>
</div>
<div class="broken-grid__item">
<picture class="visual">
<source srcset="https://picsum.photos/700" type="image/webp">
<img src="https://picsum.photos/700" alt="">
</picture>
<picture class="visual">
<source srcset="https://picsum.photos/700" type="image/webp">
<img src="https://picsum.photos/700" alt="">
</picture>
</div>
<div class="broken-grid__item">
<picture class="visual">
<source srcset="https://picsum.photos/700" type="image/webp">
<img src="https://picsum.photos/700" alt="">
</picture>
<picture class="visual">
<source srcset="https://picsum.photos/700" type="image/webp">
<img src="https://picsum.photos/700" alt="">
</picture>
</div>
<div class="broken-grid__item">
<picture class="visual">
<source srcset="https://picsum.photos/700" type="image/webp">
<img src="https://picsum.photos/700" alt="">
</picture>
<picture class="visual">
<source srcset="https://picsum.photos/700" type="image/webp">
<img src="https://picsum.photos/700" alt="">
</picture>
</div>
</div>