

CSS takes a source document organized as a tree of elements… and text nodes… and renders it onto a canvas such as your screen.
The document canvas is the infinite surface over which the document is rendered.


width/height to start from

display property
Box Generation Values
display propertyDisplay:none; (head/style) removes box & subtreeDisplay:contents; (figure?) removes boxDisplay:list-item; (li) generates a second ::marker boxList-style-position moves ::marker in or out of primary boxdisplay: none
Removes Box Tree
display: contents
Removes Box (Only)
divs when doing layoutdisplay: list-item
Adds Marker Box
list-item keyword::marker boxdisplay context…
Flow, Flex, Grid, Table-*…
Set on the container for a layout
display values are set on a container elementdisplay behavior
Inline or Block
Set on the elements of a (flow) layout
inline or block)demo:
width to editableheightdisplay: blockdisplay of the element itself…body { display: flex; }flow is the default…display: block
display: block flow;
inline » inline flowblock or inlinedisplay: block flow in modern browsers.display…
Flow or Flow-Root
flow or flow-rootdisplay: flow
display: block flow;
flex » block flexflow or flex or gridblockgrid is the same as display: block griddisplay actually doeswriting mode
[demo link]inline-size is the heightblock-size is the widthdirection
[demo link]top, right, bottom, and left (fixed in place)block-start, block-end, inline-start, inline-end(in English, for example…)
width -> inline-sizeheight -> block-sizetop -> block-startbottom -> block-endleft -> inline-startright -> inline-endmargin-right with margin-inline-endblock and inline shorthands for somemargin-block, padding-inline, border-block, etcinput {
margin-inline-end: 1em;
margin-right: 0;
}
0px if they are the same sidemargin-inline-end here0, the margin-right valueinline and block go all the way back to the startem size.flex > span {
inline-size: 50%;
}
% and other ‘relative’ units)min-content |max-content | fit-content
“A mini layout in your layout”…
overflow: hidden; to trigger a…hasLayout in IE)display: flow-root
display: block flow-root;
grid » block gridflow-root or grid)blockinline-flex, inline-grid, inline-block
inline-flex ➡️ inline flexinline-grid ➡️ inline gridinline-block ➡️ inline flow-rootinline-block nowinline flow-rootdistributing extra space
Block axis comes first
Which axis are we manipulating?
justify-* props apply to the ‘inline’ axisalign-* props apply to the ‘block’ axisstretch
start | center | end
self-* | flex-*
safe ‘clamps’ alignment at the start
-direction and -wrap (or -flow)gap on containeralign-items on the flexbox containerplace- or align-justify- in relation toplace-contentspace-between | -around | -evenlyplace-self to
Move Individual Items
Explicit on each element
place-items to
Move All Items
A default from the container
place-content to
Move Entire Layout
space-between | -around | -evenly
align-contentalign-self…
From Container Align-Items
(each item can still align-self to override)
.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!