liveBook · Manning

Radial-gradient function

As explained in Web Design Playground, Second Edition

The CSS radial-gradient() function creates a gradient image whose colors radiate outward from a central shape.

The CSS radial-gradient() function creates a background image whose colors transition outward from one point in a circle or ellipse. Think of dropping food coloring into water: the color spreads from the starting spot. section 17.8

Build the function from a few optional pieces:

  • Choose a shape: circle, the default, or ellipse. section 17.10
  • Choose an extent: closest-side, farthest-side, closest-corner, or farthest-corner. section 17.10
  • Set the starting position with x-y coordinates or keywords such as left top, center, or right bottom. section 17.10
  • Add colors and optional color stops, using the same color-stop rules as a linear gradient. section 17.10

A yellow-to-blue corner glow

div { background-color: yellow; background-image: radial-gradient(ellipse farthest-corner at left top, yellow, blue); height: 200px; width: 100%; } <div></div> This creates an ellipse beginning at the element’s top-left corner and spreading toward the farthest corner. For a simpler centered circular gradient, use radial-gradient(yellow, blue). section 17.10

Figure 17.13 Defining a radial gradient, using the radial-gradient() function to specify shape, extent, and color stops

Use the syntax figure to see how shape, extent, position, and color stops fit together. section 17.10

How Web Design Playground, Second Edition covers it

How deep it goes
Defines shape, extent, position, colors, stops, and defaults, then demonstrates a complete CSS rule.
Examples
Shows a yellow-to-blue ellipse positioned at the top-left corner and a simpler centered two-color gradient.
What it assumes
Assumes basic CSS background properties while introducing gradients, radial shapes, extent keywords, positions, and color stops.
What you can do after
Apply it via CSS by selecting a shape, extent, position, colors, and optional stops for an element background.
How it connects
Connects background-image, background-color, linear gradients, color stops, and CSS colors.

Also explained in

Compare how 2 books explain radial-gradient function →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Design Playground, Second Edition. The section links point to the parts of the book it draws on.