CSS Gradient Generator
Design beautiful linear gradients and instantly copy the CSS code for your next project.
CSS Output
background: linear-gradient(90deg, #4F46E5 0%, #EC4899 100%);Preview
Understanding CSS Gradients
Gradients allow you to display smooth transitions between two or more specified colors. CSS gradients are treated as background-image elements rather than solid colors, allowing you to layer them seamlessly.
Linear Gradients
The standard syntax involves declaring an angle or direction, followed by a series of color stops. By adjusting the angle control in the tool above, you can see how light dynamically falls across the element.
Knowledge Base & FAQ
Frequently Asked Questions
Direct answers and solutions to common questions, technical challenges, and industry standards.
Why do CSS gradients look grayish or 'muddy' in the middle?expand_more
This is known as the 'gray dead zone' phenomenon in computer graphics. When CSS interpolates between two colors (like vibrant blue and bright yellow) within the standard sRGB color space, the mathematical midpoint passes through low-saturation gray. To fix muddy gradients:
- Add an intermediate harmonious color stop in the middle (e.g. green between blue and yellow).
- Or use modern CSS Color 4 interpolation in OKLCH:
background: linear-gradient(in oklch to right, blue, yellow);which maintains human perceived brightness without desaturation.
How do I animate a CSS background gradient on hover?expand_more
Browsers cannot directly transition the
background-image property. However, you can achieve a silky 60fps gradient hover animation by making the background larger than its container and transitioning background-position: .gradient-btn {
background: linear-gradient(135deg, #4F46E5, #EC4899);
background-size: 200% 200%;
transition: background-position 0.4s ease;
}
.gradient-btn:hover {
background-position: 100% 100%;
}What is the difference between linear-gradient and radial-gradient in CSS?expand_more
linear-gradient() transitions colors along a straight directional line defined by an angle (e.g.
90deg, 135deg) or directional keyword (to bottom right). radial-gradient() radiates outward from a focal center point in concentric circles or ellipses, making it ideal for glowing ambient backdrops, spotlights, and vignette lighting.How do I create a modern glassmorphism gradient in CSS?expand_more
Glassmorphism combines semi-transparent RGBA gradient overlays with hardware-accelerated blur:
.glass-card {
background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05));
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
border: 1px solid rgba(255, 255, 255, 0.2);
border-radius: 20px;
}Do complex CSS gradients impact mobile browser performance or battery life?expand_more
No. Unlike bitmap images (PNG/WebP), CSS gradients are vector mathematical formulas evaluated directly by the device's GPU shader pipeline. They consume zero network bandwidth and negligible memory. To maximize battery efficiency, avoid repeatedly animating gradient properties that trigger layout reflows, and stick to GPU-composited
transform, opacity, or background-position transitions.