Container queries will never be possible on the web. They would cause infinite layout loops. – Browsers, A Paraphrase (circa 2020)
Truly Two-Dimensional Layouts Combine Fluid & Fixed Stages of Squishiness Nested Contexts Expand & Contract Content Media Queries, As Needed
Progressive Enhancement… /* explicit fallbacks, rarely needed */@supports not (container: name) { /* … */ }
See the Pen 💥 Inline Containment Error, Auto-sized BFCs effected by floats by @miriamsuzanne on CodePen.
@container layout (min-width: 40em) { .conditional { /* … */ }}@container main (min-width: 40em) { .conditional { /* … */ }}
Finding Containers For each matched element… Find the nearest ancestor that has… Any required container name Any required container types
/* extrinsic size, from the viewport */html, body { block-size: 100%; }/* root container */html { container: root / size; }/* body as scroller */body { overflow: auto; }
Simpler Solution… (without height queries) body > :is(header, main, footer, aside), { container: layout / inline-size;}
Things Containers Know: Their Size (if contained) Custom Property Values Relative Values (like em) Maybe Some States?? (tbd)