Company Workshop
Distributing content, and providing structure
workshops.oddbird.net/kc24/layout/
distributing extra space
Block axis comes first
Which axis are we manipulating?
justify-*
align-*
stretch
start
center
end
self-*
flex-*
safe
-direction
-wrap
-flow
gap
(each item can still align-self to override)
align-self
space
-between
-around
-evenly
.defaults { flex-basis: auto; /* starting width */ flex-shrink: 1; /* distribution factor */ flex-grow: 0; /* distribution factor */ }
auto
flex
initial | auto | none | <grow>
initial
none
<grow>
Initial
Same as 0 1 auto
0 1 auto
Auto
Same as 1 1 auto
1 1 auto
None
Same as 0 0 auto
0 0 auto
<number>
Same as <number> 1 0
<number> 1 0
Not a strict rule, just a hint!
display: grid
Generate columns & rows as needed
columns
rows
grid-<axis>-start
grid-<axis>-end
<rows>
<columns>
min-content
1fr
fit-content(
<limit>
)
clamp(auto, max-content,
with matching *-start & *-end names
*-start
*-end
as column or row template
Content Expands & Contracts ??
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, Monday
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) { … }
Navigate slides using the arrow-keys.