Advancednote 04 of 1703 reasons · 03 notes
CSSAdvanced
Use container queries for cards
Let components adapt to their own space instead of depending on the whole viewport.
Code example
Copy, adapt, and ship.
Read the numbered lines, copy the complete snippet, then adjust the values for your project.
.product-card { container-type: inline-size;} @container (min-width: 420px) { .product-card__body { display: grid; grid-template-columns: 120px 1fr; }}Why this matters
The production reason.
- 01
Viewport breakpoints are not enough when the same card appears in a sidebar, grid, modal, and dashboard.
- 02
Container queries let the component respond to its own available space.
- 03
This keeps reusable components from needing one-off parent classes everywhere.
How it holds up outside a demo.
- CSSUse container-type on the component wrapper.
- ReactGreat for reusable cards in multiple layouts.
- No-code buildersUse custom CSS when built-in breakpoints cannot handle nested layouts.
Explore other stacks
Jump into a different technology.
17 CSS notes on this shelf, and six more stacks beside it.
Use next/image for image optimization
Next.js image optimization starts with next/image sizing, lazy loading, modern formats, and predictable dimensions.
Open the noteKeep state close to the interaction
Local state avoids unnecessary parent renders and keeps component intent obvious.
Open the noteAbort stale fetch requests
Cancel outdated browser requests so fast UI changes do not render old data.
Open the noteFix WordPress H1 SEO issues
Fix WordPress SEO issues by keeping one clear H1, escaping template output, and compressing images before WordPress upload.
Open the noteReduce LCP with image optimization
Reduce LCP with image optimization by resizing, converting, and compressing images before they reach production.
Open the noteUse real buttons for actions
If it changes state, use button. If it navigates, use a link.
Open the note