Before
Traditional responsive grids often define two, three, or four columns through a chain of viewport breakpoints. A missed width can leave cards cramped, create awkward empty space, or force another maintenance rule into the stylesheet.
Design Technologist · AI-Assisted CSS Engineering
This showcase documents a self-organizing media gallery from raw semantic HTML through prompt engineering, human auditing, and a verified CSS Grid implementation that calculates its own columns.
A gallery should respond to the space it receives instead of depending on a developer predicting every useful viewport width.
Traditional responsive grids often define two, three, or four columns through a chain of viewport breakpoints. A missed width can leave cards cramped, create awkward empty space, or force another maintenance rule into the stylesheet.
CSS Grid can compare the available inline size with each card’s minimum track size. The browser then creates as many tracks as fit, wraps the remaining cards, and distributes extra space without a column-specific media query.
Six coordinated ideas allow the browser to form, wrap, size, and align the card collection without breakpoint-driven columns.
The parent owns two-dimensional track creation while each article remains a semantic grid item.
Unused tracks collapse so the cards that exist can stretch across the available row.
Each track keeps a 300px minimum while its flexible maximum shares remaining space.
Fractional tracks divide free space evenly after the minimum card widths are satisfied.
The grid parent controls card separation without directional margins on individual items.
Flexbox stacks the image and body while allowing card content regions to fill equal grid-track heights.
The content hierarchy is complete, but browser defaults still place every card in one uninterrupted block flow.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Week 04 Lab: Media-Query-Free Grid</title>
</head>
<body>
<div class="gallery-wrapper">
<header class="gallery-header">
<h1 class="gallery-title">Curated Discoveries</h1>
<p class="gallery-subtitle">A self-organizing responsive media portal.</p>
</header>
<!-- The Auto-Scaling Grid Container -->
<main class="grid-container">
<!-- Card 1 -->
<article class="media-card">
<div class="media-card__visual">
<img src="https://images.unsplash.com/photo-1451187580459-43490279c0fa?w=600" alt="Nebula space" class="media-card__img">
</div>
<div class="media-card__body">
<span class="media-card__tag">Cosmos</span>
<h2 class="media-card__heading">Deep Space Telemetry</h2>
<p class="media-card__desc">Mapping the cosmic microwave background radiation across unexplored clusters.</p>
</div>
</article>
<!-- Card 2 -->
<article class="media-card">
<div class="media-card__visual">
<img src="https://images.unsplash.com/photo-1518770660439-4636190af475?w=600" alt="Microchip" class="media-card__img">
</div>
<div class="media-card__body">
<span class="media-card__tag">Technology</span>
<h2 class="media-card__heading">Silicon Architecture</h2>
<p class="media-card__desc">How quantum computing layers are shifting the limits of traditional solid-state physics.</p>
</div>
</article>
<!-- Card 3 -->
<article class="media-card">
<div class="media-card__visual">
<img src="https://images.unsplash.com/photo-1464822759023-fed622ff2c3b?w=600" alt="Mountain peak" class="media-card__img">
</div>
<div class="media-card__body">
<span class="media-card__tag">Nature</span>
<h2 class="media-card__heading">High Alpine Ecology</h2>
<p class="media-card__desc">Documenting biodiversity changes in sub-zero alpine meadows under global shifts.</p>
</div>
</article>
<!-- Card 4 -->
<article class="media-card">
<div class="media-card__visual">
<img src="https://images.unsplash.com/photo-1504384308090-c894fdcc538d?w=600" alt="Cyberpunk city" class="media-card__img">
</div>
<div class="media-card__body">
<span class="media-card__tag">Urbanism</span>
<h2 class="media-card__heading">The Decentralized City</h2>
<p class="media-card__desc">Examining modern micro-infrastructure models in densely populated metropolitan areas.</p>
</div>
</article>
</main>
</div>
</body>
</html>
Browser defaults only
A self-organizing responsive media portal.
Image: Nebula space
Cosmos · Mapping cosmic background radiation.
Image: Microchip
Technology · Exploring quantum computing layers.
Image: Mountain peak
Nature · Documenting alpine biodiversity changes.
Image: Cyberpunk city
Urbanism · Examining metropolitan micro-infrastructure.
The drafting request converts the assignment into explicit structural, mathematical, responsive, and output-boundary requirements.
Keep the supplied semantic gallery elements and class names intact.
Apply predictable box sizing, fluid spacing, and relative typography units.
Assign the exact auto-fit and minmax track declaration to the grid parent.
Use Grid for card tracks, Flexbox inside cards, and parent gap for gutters.
Reject media-query columns, floats, fixed track counts, and child margins.
Require explainable wrapping behavior, overflow checks, comments, and CSS-only output.
Act as a senior CSS systems engineer. Generate a production-ready stylesheet for the supplied semantic media-gallery HTML without replacing its structural class system.
Implementation requirements:
1. Apply a global reset that removes default margins and padding and uses box-sizing: border-box for predictable sizing.
2. Create a fluid visual theme with relative typography and spacing units such as rem, em, percentages, and clamp() where appropriate.
3. Set .grid-container to display: grid and declare grid-template-columns exactly as repeat(auto-fit, minmax(300px, 1fr)).
4. Use gap on .grid-container as the only owner of spacing between media cards. Do not place layout margins on individual cards.
5. Build each .media-card as a vertical Flexbox component so its visual region sits above its text body and every card stretches to the full height of its grid track.
6. Make images fill their visual region without distortion by using a controlled aspect ratio and object-fit: cover.
7. Do not use @media rules, floats, fixed column counts, or breakpoint-based column sizing anywhere in the returned stylesheet.
8. Include visible focus treatment only for elements that are actually interactive, preserve readable contrast, and prevent the gallery from creating page-level overflow.
9. Add concise comments explaining how auto-fit collapses unused tracks, how minmax() protects the 300px minimum, and how 1fr distributes remaining space.
Return only the complete CSS stylesheet.
The stylesheet is accepted only after its track formula, spacing ownership, card internals, and prohibited techniques are inspected directly.
*,
*::before,
*::after {
box-sizing: border-box;
}
body {
margin: 0;
font-family: system-ui, sans-serif;
}
.gallery-wrapper {
inline-size: min(100% - 2rem, 80rem);
margin-inline: auto;
padding-block: 3rem;
}
.grid-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 1.25rem;
}
.media-card {
display: flex;
flex-direction: column;
block-size: 100%;
overflow: hidden;
border-radius: 1rem;
}
.media-card__visual {
aspect-ratio: 16 / 10;
}
.media-card__img {
inline-size: 100%;
block-size: 100%;
object-fit: cover;
}
.media-card__body {
display: flex;
flex: 1;
flex-direction: column;
gap: 0.75rem;
padding: 1.25rem;
}
Human audit targets:
@media
float
margin on .media-card
grid-template-columns
repeat(auto-fit, minmax(300px, 1fr))
Expected findings:
- No @media syntax in the generated gallery stylesheet.
- No floats or fixed column counts.
- One exact required grid-template-columns declaration.
- Card separation owned by .grid-container gap.
- Flexbox used inside every .media-card.
The grid declares repeat(auto-fit, minmax(300px, 1fr)) exactly as required.
The gallery-specific CSS contains no breakpoint rule for columns, card sizing, or layout changes.
Empty tracks collapse, allowing existing cards to stretch instead of reserving unused columns.
Card separation belongs to .grid-container, not to margins on each article.
Every card is a vertical flex container whose body can grow to match neighboring card heights.
A fixed aspect ratio and object-fit: cover prevent image distortion and layout jumps.
The draft uses native Grid and Flexbox responsibilities rather than legacy fallback positioning.
The required 300px track minimum is preserved and exceptional narrow overflow stays inside the demonstration surface.
The browser decides how many cards fit on each row while every card keeps the same minimum track width and proportional share of free space.
A self-organizing responsive media portal.
Mapping the cosmic microwave background radiation across unexplored clusters.
How quantum computing layers are shifting the limits of traditional solid-state physics.
Documenting biodiversity changes in sub-zero alpine meadows under global shifts.
Examining modern micro-infrastructure models in densely populated metropolitan areas.
auto-fit creates only the columns that fit and collapses unused tracks.
minmax(300px, 1fr) protects readability while still permitting proportional expansion.
The parent gap keeps spacing consistent without margins leaking from individual cards.
The final gallery is accepted only after its computed tracks, wrapping behavior, source constraints, and portfolio integration are inspected.
.grid-container and confirm its computed display value is grid.grid-template-columns is authored as repeat(auto-fit, minmax(300px, 1fr)).gap..media-card and confirm it is a vertical Flexbox container.object-fit: cover.@media, float, and fixed column-count declarations; none should be present.responsive-grid-showcase.html compatibility file was created for this brand-new route.AI drafted the CSS. Human auditing verified intrinsic grid behavior, source constraints, accessibility boundaries, and portfolio preservation.