Smashing Workshop
imposing structure on the page
workshops.oddbird.net/smashing24/grid/
(but makes CQs impossible)
Container queries will never be possible on the web. They would cause infinite layout loops.
— Browsers, a paraphrase (circa 2020)
contain: size | layout | style | paint;
Block boxes get their inline-size from Context (extrinsic).
inline-size
— Me, yesterday
Block boxes get their block-size from Content (intrinsic).
block-size
size
container-type: inline-size;
contain
: inline-size layout style;
main { container: layout main / inline-size; }
container-name
/ container-type
@container layout (min-width: 40em) { .conditional { /* … */ } } @container main (min-width: 40em) { .conditional { /* … */ } }
(That would introduce loops!)
(can’t change what you measure!)
No element to measure…
body > :is(header, main, footer, aside) { container: layout / inline-size; }
cqw | cqh | cqi | cqb | cqmin | cqmax
cqw
cqh
cqi
cqb
cqmin
cqmax
@container style(--colors: invert) { … }
Unless you query a specific container-name
* for now ** ** but maybe forever?
@container state(stuck) { … } @container state(snapped) { … } @container state(overflowing) { … }
/* explicit fallbacks, rarely needed */ @supports not (container: name) { /* … */ }
GoogleChromeLabs/container-query-polyfill
skip…
.grid-span { width: percentage( /* 23.7288136% */ ((3 * 4em) + (2 * 1em)) / ((12 * 4em) + (11 * 1em)) ); margin-right: percentage( /* 01.6949153% */ 1em / ((12 * 4em) + (11 * 1em)) ); padding-left: percentage( /* 08.4745763% */ ((1 * 4em) + (1 * 1em)) / ((12 * 4em) + (11 * 1em)) ); }
Generate columns & rows as needed
columns
rows
column | column [+ dense]
column
dense
grid-<axis>-start
grid-<axis>-end
<tracks>
min-content
1fr
fit-content(
<limit>
)
clamp(auto, max-content,
with matching *-start & *-end names
*-start
*-end
repeat( <count>, <tracks> )
repeat(
<count>, <tracks>
as column or row template
Navigate slides using the arrow-keys.