CSS Gradients


Gradients

There are three types of gradients:

These each take 2 or more colors which are stepped through by the gradient function. There are further optional arguments described below.

There are also repeating- versions of each function.

Direction

The optional first argument to a gradient function sets the direction. It can either be a key phrase or an angle.

Each of the following key phrases are valid:

Valid units for angles are:

.gradient {
  linear-gradient(to left top, #fff, #000);
}

Color Hints

Color Stops


Animated Gradients

Gradients are images and as such cannot be directly animated. Instead apply a transition effect on their position.

.gradient {
  background-image: linear-gradient(45deg, #fff, #000);
  background-size: 300%;
  background-position: left;
  transition: background-position 1s;
}

.gradient:hover {
  background-position: right;
}


CategoryRicottone

CSS/Gradients (last edited 2022-01-28 21:44:25 by DominicRicottone)