CSS Radial Gradients
Subject: css
CSS Radial Gradients
Radial gradients in CSS create color transitions that radiate outward from a central point. Unlike linear gradients that move along a straight line, radial gradients spread in circles or ellipses—making them ideal for spotlight effects, buttons, backgrounds, and design accents.
Syntax
Parameters:
- Shape (optional):
circleorellipse - Size (optional):
closest-side,farthest-side,closest-corner,farthest-corner - Position (optional):
center,top left,50% 50%, etc. - Color Stops: List of colors used in the gradient
Example 1: Default Radial Gradient
This creates an elliptical gradient starting from the center and radiating outward.
Example 2: Circular Radial Gradient from Top Left
This places the gradient center at the top-left of the element and makes it circular.
Example 3: Using Shape and Size
circlemakes the shape roundclosest-sidelimits the radius to the closest edge from center
Transparency with Radial Gradients
This is useful for creating overlay or spotlight effects and can be applied over images or sections.
Best Practices
- Ensure text contrast when using gradients as backgrounds
- Use
circlefor buttons or focus highlights - Use
rgba()with transparency for overlays and depth - Avoid overusing gradients to prevent visual clutter
Key Takeaways
- Radial gradients spread color from a center point outward
- Shape can be set as
circleorellipse - Customize with size, position, and color stops
- Great for UI design, focus areas, and visual layering
Advertisement Slot 1
Advertisement Slot 2