<div class="container">
<div class="grid">
<div class="box">
<div class="img-wrap">
<img src="https://loremflickr.com/800/500/grid" alt="" width="800" height="500" />
</div>
<h1 class="title">Short title, short text</h1>
<div class="content">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Maiores magni reiciendis eveniet facilis consectetur nemo maxime molestiae numquam fugiat excepturi nam placeat, perspiciatis dolor, vel distinctio quis assumenda quia deleniti!</p>
</div>
<div class="actions">
<button class="button">Details</button>
<button class="button">Buy</button>
</div>
</div>
<div class="box">
<div class="img-wrap">
<img src="https://loremflickr.com/800/500/grid" alt="" width="800" height="500" />
</div>
<h1 class="title">Very extremely long title, with long text</h1>
<div class="content">
<p>Shorter body copy</p>
</div>
<div class="actions">
<button class="button">Details</button>
<button class="button">Buy</button>
</div>
</div>
<div class="box">
<div class="img-wrap">
<img src="https://loremflickr.com/800/500/grid" alt="" width="800" height="500" />
</div>
<h1 class="title">Short title, short text</h1>
<div class="content">
<p>lorem</p>
</div>
<div class="actions">
<button class="button">Details</button>
<button class="button">Buy</button>
</div>
</div>
<div class="box">
<div class="img-wrap">
<img src="https://loremflickr.com/800/500/grid" alt="" width="800" height="500" />
</div>
<h1 class="title">Short title, short text</h1>
<div class="content">
<p>lorem</p>
</div>
<div class="actions">
<button class="button">Details</button>
<button class="button">Buy</button>
</div>
</div>
<div class="box">
<div class="img-wrap">
<img src="https://loremflickr.com/800/500/grid" alt="" width="800" height="500" />
</div>
<h1 class="title">Very extremely long title, with long text</h1>
<div class="content">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Maiores magni reiciendis eveniet facilis consectetur nemo maxime molestiae numquam fugiat excepturi nam placeat, perspiciatis dolor, vel distinctio quis assumenda quia deleniti!</p>
</div>
<div class="actions">
<button class="button">Details</button>
<button class="button">Buy</button>
</div>
</div>
</div>
</div>
.grid {
display: grid;
grid-template-columns: repeat(6, minmax(0, 1fr));
gap: 1.25rem;
padding: 2rem;
}
.box {
grid-column: span 2;
grid-row: span 4;
}
.grid:has(.box:nth-child(3n + 5):last-child) .box:nth-last-child(2) {
grid-column: 2 / span 2;
}
.box:nth-child(3n + 4):last-child {
grid-column: 3 / span 2;
}
@supports (grid-template-rows: subgrid) {
.box {
display: grid;
gap: 0;
grid-template-rows: subgrid;
}
}
@supports not (grid-template-rows: subgrid) {
.box {
display: flex;
flex-direction: column;
}
.box .content {
flex: 1;
}
}
.box .title {
margin: 0;
padding: 1rem;
background: #f2ead9;
}
.box .content {
margin: 0;
padding: 1rem;
background: #f6f0e4;
}
.box .actions {
padding: 1rem;
background: #faf7f0;
}
.box img {
width: 100%;
height: 200px;
object-fit: cover;
display: block;
}
body {
background: radial-gradient(circle at bottom right, #eee, #ccc);
margin: 0;
min-height: 100vh;
}
.container {
max-width: 1200px;
margin-inline: auto;
padding-inline: 1rem;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.