bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
Learn/CSS/Advanced Styling
CSS•Advanced Styling

CSS Radial Gradients

CSS radial-gradient() Function

The CSS radial-gradient() function creates a radial gradient.

A radial gradient defines a color transition that goes goes out from a central point.

A radial gradient requires at least two color stops. Color stops are the colors you want to render smooth transitions among.

Syntax

background-image: radial-gradient( shape size
at
position, start-color, ..., last-color );

By default, shape is ellipse, size is farthest-corner, and position is center.

Radial Gradient - Evenly Spaced Color Stops (this is default)

The following example shows a radial gradient with evenly spaced color stops:

Example

Formatted code
#grad {
  background-image: radial-gradient(red, yellow, green);
}

Live preview

Radial Gradient - Differently Spaced Color Stops

The following example shows a radial gradient with differently spaced color stops:

Example

Formatted code
#grad {
  background-image: radial-gradient(red 5%, yellow 15%, green 60%);
}

Live preview

Radial Gradient - Set Shape

The shape parameter defines the shape of the gradient. It can take one of the following values:

  • ellipse (this is default)
  • circle

The following example shows a radial gradient with the shape of a circle:

Example

Formatted code
#grad {
  background-image: radial-gradient(circle, red, yellow, green);
}

Live preview

Radial Gradient - The size Parameter

The size parameter defines the size of the gradient'ending shape. It can take one of the following values:

  • closest-side
  • farthest-side
  • closest-corner
  • farthest-corner (this is default)

Example

Formatted code
#grad1 {
  background-image: radial-gradient(closest-side at 70% 60%, red, yellow, black);
}
#grad2 {
  background-image: radial-gradient(farthest-side at 70% 60%, red, yellow, black);
}

Live preview

CSS repeating-radial-gradient() Function

The CSS repeating-radial-gradient() function is used to repeat radial gradients:

Example

Formatted code
#grad {
  background-image: repeating-radial-gradient(red, yellow 10%, green 15%);
}

Live preview

Previous

CSS Gradients

Next

CSS Conic Gradients

This chapter

Overview
53

Lessons

154m

Read time

1. CSS Rounded Corners2. Sass Tutorial3. CSS Border Images4. CSS Multiple Backgrounds5. CSS Background Size6. CSS Background Origin7. CSS Background Clip8. CSS Colors9. CSS Color Keywords10. CSS Gradients11. CSS Radial Gradients12. CSS Conic Gradients13. CSS Shadow Effects14. CSS Box Shadow15. CSS Text Effects16. CSS Custom Fonts17. CSS 2D Transforms18. CSS 2D Transform Scale19. CSS 2D Transform Skew / Matrix20. CSS 3D Transforms21. CSS Transitions22. CSS Transition Timing23. CSS Animations24. CSS Animation Timing25. CSS Animation Properties26. CSS Tooltip27. CSS Tooltip Arrows28. CSS Styling Images29. CSS Image Effects30. CSS Image Hover Overlays31. CSS Responsive Modal Images32. CSS Centering Images33. CSS Image Filter Effects34. CSS Image Shapes35. CSS object-fit Property36. CSS object-position Property37. CSS Masking38. CSS Gradient Mask Layers39. CSS SVG Mask Layers40. CSS Styling Buttons41. CSS Button Hover Effects42. CSS Button Groups43. CSS Pagination Styles44. CSS Multiple Columns45. CSS Column Rules46. CSS User Interface47. CSS Variables - var() Function48. CSS Overriding Variables49. CSS Variables and JavaScript50. CSS Variables in Media Queries51. CSS @property Rule52. CSS Box Sizing53. CSS Media Queries

On this page

CSS radial-gradient() FunctionRadial Gradient - Evenly Spaced Color Stops (this is default)Radial Gradient - Differently Spaced Color StopsRadial Gradient - Set ShapeRadial Gradient - The size ParameterCSS repeating-radial-gradient() Function