CSS
Layout, centering, and the snippets you re-google every week.
Center anything
flexboxgridlayoutFlexbox is the shortest path to both-axis centering. `place-items: center` on a grid does the same in one line if the parent has a height.
Flexbox essentials
flexboxlayoutgapFlex works on one axis at a time. Set `flex-direction` first, then reason about `justify-content` (main axis) and `align-items` (cross axis). `gap` replaces margin hacks.
Grid essentials
gridresponsivelayoutGrid is two-dimensional. `repeat(auto-fit, minmax(...))` gives a responsive card layout without a single media query.
Truncate and clamp text
textoverflowellipsisSingle-line truncation needs `overflow`, `white-space`, and `text-overflow` together. Multi-line uses the widely supported `-webkit-line-clamp`.
Sticky header that actually sticks
positionstickyz-index`position: sticky` fails silently when an ancestor has `overflow: hidden`/`auto`, or when no offset is set. Give it a `top` and check the ancestor chain.