Aligning Content beside an Image
suggest changeGrid can size an image column and vertically align adjacent details:
<article class="feature">
<img class="feature__image" src="feature.jpg" alt="…">
<div class="feature__details">
<h2>Title</h2>
<p>Description…</p>
<button type="button">Action</button>
</div>
</article>
.feature {
display: grid;
grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr);
align-items: center;
gap: 2rem;
}
.feature__image {
inline-size: 100%;
block-size: auto;
}
@media (width < 48rem) {
.feature {
grid-template-columns: 1fr;
}
}
Unlike table-display emulation, the grid explicitly describes the two tracks and can collapse to one column when the available space is limited.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents