Content-Aware Card Component

This demo illustrates a semantic card component. By querying its parent layout wrapper container using Container Queries and modern :has() selectors, the card automatically reconfigures its layout structure dynamically.

Example 1 — Card Layout in Narrow Viewport (Static Mobile Preview)

A static mobile preview of the card with an image. Because the container is narrow (under 32rem / 512px), the card naturally stacks elements vertically in their exact HTML source order.

Poached Eggs

Poached Eggs

Breakfast Special

Two perfectly poached organic eggs served on fresh toasted sourdough bread with microgreens.

Example 2 — Same Card in Wide Viewport (Static Desktop Preview)

The exact same HTML card, rendered inside a wider layout container (e.g., 600px wide). The card automatically detects the spacious container and shifts elements into a clean two-column sidebar layout.

Poached Eggs

Poached Eggs

Breakfast Special

Two perfectly poached organic eggs served on fresh toasted sourdough bread with microgreens.

Example 3 — Same Card in Resizable Sandbox (Interactive Resizer)

Drag the handle in the bottom-right corner of the container to watch the card seamlessly transition between stacked mobile and two-column sidebar layouts as its width changes!

Poached Eggs

Poached Eggs

Breakfast Special

Two perfectly poached organic eggs served on fresh toasted sourdough bread with microgreens.

Example 4 — Text-Only Card in Resizable Sandbox (Interactive Resizer)

The simplest card: a heading and a paragraph, with no media and no wrappers. Because it has no media element, it keeps a single-column text layout at every container size.

Culinary Philosophy

Sourcing exclusively local, organic ingredients supports sustainable agriculture, and serving handcrafted meals cooked from scratch every single day.

Example 5 — Cards With Different Regions Aligned With Subgrid

Three cards share four row tracks (media, header, content, footer). Each omits a different region, and the regions they do have still line up. The middle card has two paragraphs, so its content region is wrapped.

Poached Eggs

Poached Eggs

Two poached eggs on toasted sourdough.

Weekend Brunch

By the kitchen team

Served from ten until two every Saturday and Sunday.

Reservations recommended for parties of six or more.

Seasonal Menu

Spring edition

New dishes built around local asparagus and early strawberries.