CSS Gradient Techniques Every Designer Should Know
CSS gradients have evolved from simple two-color fades into a powerful design tool capable of creating complex, beautiful backgrounds without a single image file. Here are the techniques every designer should master.
Linear Gradients
The most common gradient type. Specify a direction and two or more color stops: linear-gradient(135deg, #ea580c, #9333ea). The angle determines the gradient direction โ 0deg goes up, 90deg goes right, 135deg goes diagonally.
Radial Gradients
Radial gradients emanate from a center point: radial-gradient(circle, #ea580c, transparent). Use them for spotlight effects, glowing elements, or soft vignettes. Combine with positioning to create off-center light sources.
Multi-Stop Gradients
Add more than two colors for richer effects. Control the transition points with percentages: linear-gradient(90deg, #ea580c 0%, #f59e0b 50%, #9333ea 100%). Sharp transitions at the same percentage create hard lines โ useful for striped patterns.
Layered Gradients
Stack multiple gradients for complex effects. Combine a radial glow with a linear gradient: background: radial-gradient(ellipse at top, #ea580c15, transparent), linear-gradient(180deg, #0c0a09, #1c1917). This technique creates the depth and atmosphere you see in premium hero sections.
Performance Tips
- Gradients are rendered by the GPU โ they cost almost nothing in performance.
- Replace gradient images with CSS gradients to eliminate HTTP requests.
- Use
background-sizewith repeating gradients for patterns. - Animate gradients by transitioning
background-position, not the gradient itself.