The cubic-bezier()
functional notation defines a cubic Bézier curve. The easing functions in the cubic-bezier subset of easing functions are often called "smooth" easing functions because they can be used to smooth down the start and end of the interpolation. They correlate an input ratio to an output ratio, both expressed as <number>
s. For these values, 0.0
represents the initial state, and 1.0
represents the final state.
A cubic Bézier curve is defined by four points: P0, P1, P2, and P3.
- The points P0 and P3 represent the start and the end of the curve. In CSS, these points are fixed as the coordinates are ratios (the abscissa the ratio of time, the ordinate the ratio of the output range).
- P0 is
(0, 0)
and represents the initial time or position and the initial state. - P3 is
(1, 1)
and represents the final time or position and the final state.
Not all cubic Bézier curves are suitable as easing functions because not all are mathematical functions; i.e., curves that for a given abscissa have zero or one value. With P0 and P3 fixed as defined by CSS, a cubic Bézier curve is a function, and is therefore valid, if and only if the abscissas of P1 and P2 are both in the [0, 1]
range.
Cubic Bézier curves with the P1 or P2 ordinate outside the [0, 1]
range can cause the value to go farther than the final state and then return. In animations, for some properties, such as left
or right
, this creates a kind of "bouncing" effect.
However, certain properties will restrict the output if it goes outside an allowable range. For example, a color component greater than 255
or smaller than 0
will be clipped to the closest allowed value (255
and 0
, respectively). Some cubic-bezier()
curves exhibit this property.
When you specify an invalid cubic-bezier
curve, CSS ignores the whole property.
The cubic-bezier()
function can also be specified using these keywords, each of which represent a specific cubic-bezier()
notation: ease
, ease-in
, ease-out
, and ease-in-out
.