.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))
);
}
.parent {
display: flex;
gap: 1em;
}
.child { flex: 1; }
-direction
and -wrap
(or -flow
)gap
on containeralign-items
on the flexbox containerplace-
or align-
justify-
in relation toplace-content
space-between
| -around
| -evenly
.defaults {
flex-basis: auto; /* starting width */
flex-shrink: 1; /* distribution factor */
flex-grow: 0; /* distribution factor */
}
auto
content sizeflex
Shorthand Values
initial
| auto
| none
| <grow>
Initial
Shrink, If Necessary
Same as 0 1 auto
Auto
Shrink or Grow
Same as 1 1 auto
None
Don’t Flex
Same as 0 0 auto
<number>
Share Space Equally
Same as <number> 1 0
<grow>
Not a strict rule, just a hint!
justify/place-content
or align-items/self
align-content
inset
valuesNO.
— The Browsers
Not Ever.
— The Browsers
Stop Asking.
— The Browsers
Container queries will never be possible on the web. They would cause infinite layout loops.
— The Browsers
contain: size | layout | style | paint;
inline-size
For Most Containers
size
For Scroll Containers
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
@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) { … }