<div class="auto-grid">
<div>
<article class="card">
<div class="card__media">
<img src="https://source.unsplash.com/F-B7kWlkxDQ/1200x675" alt="A turntable with a brigh orange vinyl on it" />
</div>
<div class="[ card__content ] [ flow ]">
<h2>Join the Vinyl revolution</h2>
<p>
Donec id elit non mi porta gravida at eget metus. Aenean lacinia bibendum
nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum
faucibus dolor auctor.
</p>
<a href="#" class="button">Find out more</a>
</div>
</article>
</div>
<div>
<article class="card">
<div class="card__media">
<img src="https://source.unsplash.com/F-B7kWlkxDQ/1200x675" alt="A turntable with a brigh orange vinyl on it" />
</div>
<div class="[ card__content ] [ flow ]">
<h2>Join the Vinyl revolution</h2>
<p>
Donec id elit non mi porta gravida at eget metus. Aenean lacinia bibendum
nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum
faucibus dolor auctor.
</p>
<a href="#" class="button">Find out more</a>
</div>
</article>
</div>
<div>
<article class="card">
<div class="card__media">
<img src="https://source.unsplash.com/F-B7kWlkxDQ/1200x675" alt="A turntable with a brigh orange vinyl on it" />
</div>
<div class="[ card__content ] [ flow ]">
<h2>Join the Vinyl revolution</h2>
<p>
Donec id elit non mi porta gravida at eget metus. Aenean lacinia bibendum
nulla sed consectetur. Vivamus sagittis lacus vel augue laoreet rutrum
faucibus dolor auctor.
</p>
<a href="#" class="button">Find out more</a>
</div>
</article>
</div>
</div>
/* THE CONTAINER QUERY IS ON LINE 86 */
body {
font-family: "Inter", sans-serif;
max-width: 50rem;
padding: 2rem 1.5rem;
margin: 0 auto;
color: #241623;
background: #eef2f4;
}
main {
contain: layout inline-size;
}
h1 {
font-weight: 900;
font-size: 3rem;
line-height: 1.1;
}
h2 {
font-weight: 900;
font-size: 2.5rem;
line-height: 1.1;
}
p {
max-width: 60ch;
}
.card {
--flow-space: 1rem;
background: #ffffff;
border-radius: 1em;
overflow: hidden;
box-shadow: 0 0 20px hsl(0 0% 0% / 10%);
max-width: 30rem;
}
.card__content {
padding: 1.5rem;
}
.card h2 {
font-weight: 900;
font-size: 1.8rem;
line-height: 1.1;
}
.card__media {
aspect-ratio: 16/9;
}
.button {
display: inline-block;
background: #8cfbde;
color: #000000;
padding: 0.5rem 1rem;
font: inherit;
font-weight: 900;
text-decoration: none;
letter-spacing: 0.03ch;
text-transform: uppercase;
border-radius: 0.8em;
}
.flow > * + * {
margin-top: var(--flow-space, 1em);
}
hr {
margin: 3em 0;
border: unset;
border-top: 1px solid #cccccc;
}
@supports (aspect-ratio: 16/9) {
.card__media img {
width: 100%;
height: 100%;
object-fit: cover;
}
}
@container (min-width: 40em) {
.card {
display: flex;
align-items: flex-start;
gap: 1.5rem;
padding: 1.5rem;
max-width: unset;
}
.card h2 {
font-size: 2.5rem;
}
.card__media {
aspect-ratio: 1/1;
flex-basis: 30%;
flex-shrink: 0;
}
.card__media img {
border-radius: 0.5em;
}
.card__content {
padding: 0;
}
}
.auto-grid {
display: flex;
flex-wrap: wrap;
align-content: flex-start;
gap: 1rem;
}
.auto-grid > * {
flex-basis: 40%;
flex-grow: 1;
contain: layout inline-size;
}
setTimeout(() => window.scrollTo(0, document.body.scrollHeight), 500);
This Pen doesn't use any external JavaScript resources.