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

CSS Conic Gradients

CSS Conic Gradients

A conic gradient is characterized by color transitions rotating around a central point.

To generate a conic gradient, it’s necessary to specify a minimum of two colors.

Syntax

background-image: conic-gradient([from angle] [at position,] color [degree], color [degree], …);

By default, the angle is set to 0 degrees and the position is centered.

When no specific degree is provided, the colors will be evenly distributed around the central point.

Conic Gradient: Three Colors

Below is an example demonstrating a conic gradient featuring three colors:

Image

 

Example 

A conic gradient showcasing three colors.

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

Conic Gradient: Five Colors

Conic Gradient with Five Colors:

Image

Example 

A conic gradient featuring five colors.

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

Conic Gradient: Three Colors and Degrees

Below is an example demonstrating a conic gradient with three colors, each specified with a degree:

Image

Example 

A conic gradient featuring three colors, each assigned a degree value.

#grad {
  background-image: conic-gradient(red 45deg, yellow 90deg, green 210deg);
}

Create Pie Charts

To achieve a pie-like appearance for the conic gradient, simply include border-radius: 50%.

Image

 

Example 

#grad {
  background-image: conic-gradient(red, yellow, green, blue, black);
  border-radius: 50%;
}

Here is another pie chart where all colors have specified degrees:

Image

 

Example 

#grad {
  background-image: conic-gradient(red 0deg, red 90deg, yellow 90deg, yellow 180deg, green 180deg, green 270deg, blue 270deg);
  border-radius: 50%;
}

Conic Gradient With Specified From Angle

The [from angle] determines the angle by which the entire conic gradient is rotated.

Below is an example illustrating a conic gradient with a from angle set to 90 degrees:

Image

Example 

A conic gradient featuring a specified from angle.

#grad {
  background-image: conic-gradient(from 90deg, red, yellow, green);
}

Conic Gradient With Specified Center Position

The [at position] parameter designates the center of the conic gradient.

Below is an example demonstrating a conic gradient with a center position defined as 60% 45%:

Image

Example 

A conic gradient featuring a defined center position.

#grad {
  background-image: conic-gradient(at 60% 45%, red, yellow, green);
}

Repeating a Conic Gradient

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

Image

 

Example 

A conic gradient that repeats.

#grad {
  background-image: repeating-conic-gradient(red 10%, yellow 20%);
  border-radius: 50%;
}

Below is a repeating conic gradient with specified color starts and stops:

Image

 

Example 

Here is a repeating conic gradient featuring defined color starting points and color stopping points:

#grad {
  background-image: repeating-conic-gradient(red 0deg 10deg, yellow 10deg 20deg, blue 20deg 30deg);
  border-radius: 50%;
}