Curriculum
Course: CSS Advanced
Login

Curriculum

CSS Advanced

CSS Rounded Corners

0/1

CSS Border Images

0/1

CSS Color Keywords

0/1

CSS Text Effects

0/1

CSS 2D Transforms

0/1

CSS 3D Transforms

0/1

CSS Transitions

0/1

CSS Animations

0/1

CSS Tooltip

0/1

CSS Style Images

0/1

CSS Image Reflection

0/1

CSS Masking

0/1

CSS Buttons

0/1

CSS Multiple Columns

0/1

CSS User Interface

0/1

CSS Box Sizing

0/1

CSS Media Queries

0/1
Text lesson

Radial Gradients

When creating a radial gradient, it’s essential to specify a minimum of two color stops.

Syntax

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

By default, the shape is an ellipse, the size is determined by the farthest corner, and the position is centered.

Radial Gradient with Evenly Spaced Color Stops (default behavior)

Below is an example demonstrating a radial gradient with color stops evenly spaced:

Image

Example 

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

Radial Gradient – Differently Spaced Color Stops

Below is an example illustrating a radial gradient with color stops that are spaced differently:

Image

 

Example 

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

Set Shape

The shape parameter specifies the shape of the radial gradient, which can be set to either circle or ellipse, with the default being ellipse.

Below is an example demonstrating a radial gradient with a circular shape:

Image

Example 

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

Use of Different Size Keywords

The size parameter determines the extent of the gradient, offering four options:

  1. closest-side
  2. farthest-side
  3. closest-corner
  4. farthest-corner

Example 

A radial gradient showcasing various size keywords.

#grad1 {
  background-image: radial-gradient(closest-side at 60% 55%, red, yellow, black);
}

#grad2 {
  background-image: radial-gradient(farthest-side at 60% 55%, red, yellow, black);
}

Repeating a radial-gradient

The repeating-radial-gradient() function is employed to create repeating patterns of radial gradients.

Image

 

Example 

A radial gradient that repeats.

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