Gradients and Transitions
Gradients
- Gradients are created by starting with one color and transitioning to another color (which can happen potentially many times).
- They can be linear, angled, circular, and ellipse.
- Gradients leverage the
backgroundproperty.
| Gradient Type | Values |
|---|---|
| linear-gradient |
|
| radial-gradient | The first value indicates how big the ending shape should be:
The above keyword is also paired up with a size unit, which determines where the gradient intercepts the containing element The remaining values are colors for the gradient |
linear-gradient Example
See the Pen Linear Gradient by Jason Withrow (@jwithrow) on CodePen.
radial-gradiant Example
See the Pen Radial Gradient by Jason Withrow (@jwithrow) on CodePen.
Transitions
- Transitions are triggered on hover and/or focus, determining how the browser visually shifts from the current appearance to the hover and/or focus appearance.
- Essentially, they add visual appeal to what would otherwise be an immediate style change. That said, it is easy to overdo these, or otherwise implement them poorly (for example, having the transition be very slow), and annoy the user.
| Property | Usage and Effect | Values |
|---|---|---|
| transition-duration | The number of seconds for the transition (higher values mean that the transition is more drawn out) |
|
| transition-property | Specifies the CSS property that will trigger a transition when its value changes or all |
|
| transition-timing-function | Specifies the speed curve of the transition effect |
|
| transition | Shorthand for the other properties |
|
transition Example
See the Pen Transitions by Jason Withrow (@jwithrow) on CodePen.