Intermediatenote 05 of 1703 reasons · 03 notes
CSSIntermediate
Animate transform and opacity
These properties keep motion smoother on repeated UI elements and dense dashboards.
Code example
Copy, adapt, and ship.
Read the numbered lines, copy the complete snippet, then adjust the values for your project.
.menu { opacity: 0; transform: translateY(8px) scale(0.98); transition: opacity 180ms ease, transform 180ms ease;} .menu[data-open="true"] { opacity: 1; transform: translateY(0) scale(1);}Why this matters
The production reason.
- 01
Animating width, height, top, or left can force layout recalculation on every frame. That gets rough in lists, dashboards, and repeated UI.
- 02
Transform and opacity are easier for browsers to composite smoothly, so hover states, menus, sheets, and notification stacks feel cleaner.
- 03
For production UI, animate the layer, not the document flow. Reserve the final space first, then move or fade the element inside it.
How it holds up outside a demo.
- TailwindPrefer transition-transform, translate-y, scale, and opacity classes.
- Framer MotionAnimate x/y/scale/opacity instead of layout dimensions when possible.
- Shopify or WordPress menusAvoid animating max-height for large dropdowns; use opacity plus transform on a reserved panel.
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