Container Query
CSS Container Query
A conditional rule applying styles based on the size of a parent container rather than the viewport.
Detalle técnico
CSS Container Querys require a containment context declared with container-type: inline-size on the parent element. The @container rule then queries the container's dimensions rather than the viewport. Container query units (cqw, cqh, cqi, cqb) resolve relative to the query container. This enables truly reusable components that adapt to their available space regardless of viewport size — solving the long-standing limitation of media queries in component-based architectures.
Ejemplo
```css
.card-wrapper {
container-type: inline-size;
container-name: card;
}
@container card (min-width: 400px) {
.card { flex-direction: row; }
.card-image { width: 40%; }
}
```