Skip to content
Product and web UIguide

How to switch icon treatments when a card changes width

By SkeuDesign Editorial Team1 min read

Answer in brief

Use a container query when the same component appears in both a narrow sidebar and a wide content column. A viewport breakpoint cannot distinguish those two placements on the same screen.

Compare two live instances

Set container-type: inline-size on each card wrapper. Query its width to reduce the child illustration or hide purely decorative accents. Render both variants side by side at the same browser width.

Query the intended ancestor

Nested components may each establish a query container. Give the card's container a name when a badge deep inside the card needs to respond to that outer width. Put the same badge inside a narrow inner wrapper and verify that narrowing only the wrapper does not trigger the card-specific change.

Sources

  1. [1] CSS container queries - CSS — MDN Web Docs, accessed November 23, 2026

Frequently asked questions

Which element should the query style?

Apply the matching styles to descendants of the query container. Keep the wrapper responsible for the measured width.