Container Query

You might say

The same product card looks great in the wide main column, but gets squished inside the narrow sidebar even though the desktop screen is wide.

A CSS rule that lets a component adapt its layout to the width of its own parent container rather than the entire browser viewport.When one card lives in both a 760px main column and a 240px sidebar, @media only sees the 1280px desktop window and cramps the sidebar copy. Declaring container-type: inline-size on the slot wrapper and styling with @container lets the card switch between stacked and horizontal layouts automatically. Container queries complement page-level viewport breakpoints rather than replacing full-page navigation rules.
@containercontainer-typeContainer Queries

You can say this to an AI Agent

Ready to paste into Cursor, Claude Code, or Codex
Structured AI Agent prompt

This card is reused in both the wide main column and the narrow sidebar. Switch it to CSS container queries: add `container-type: inline-size` on the slot wrapper and use `@container (min-width: 380px)` to toggle between stacked and horizontal layouts instead of `@media`. Verify both the wide column and narrow sidebar on desktop afterward.

Want your Agent to translate plain-language UI ideas automatically?Install free VibeHub Skill →
Oil UI Pro. Push AI’s design skills to the limit. Usability, existing projects and stricter review.
Further reading