Grid essentials
Grid is two-dimensional. `repeat(auto-fit, minmax(...))` gives a responsive card layout without a single media query.
#grid#responsive#layout
css
.cards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 1.25rem;
}
.sidebar-layout {
display: grid;
grid-template-columns: 240px 1fr;
}
.span-two { grid-column: span 2; }Related
Flexbox essentials
Flex 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.
Truncate and clamp text
Single-line truncation needs `overflow`, `white-space`, and `text-overflow` together. Multi-line uses the widely supported `-webkit-line-clamp`.