cubic-bezier() CSS Function
The cubic-bezier() easing function defines a custom easing curve with four numbers, controlling how a transition or animation speeds up and slows down.
Description
The cubic-bezier() CSS function defines a custom easing curve for transitions and animations using a cubic Bézier curve. It controls how the speed of a change varies over time, for example starting slowly and finishing quickly, or overshooting the target and settling back. It is used with transition-timing-function, animation-timing-function and their shorthands.
The curve always starts at point (0, 0) and ends at (1, 1). The four numbers you provide are the coordinates of two control points, (x1, y1) and (x2, y2), which bend the curve between those ends. The x values represent time and must be between 0 and 1. The y values represent progress and can go outside that range: values above 1 make the animation overshoot, and values below 0 make it pull back before it starts. The common keywords are all cubic Bézier curves: ease is cubic-bezier(0.25, 0.1, 0.25, 1), ease-in is cubic-bezier(0.42, 0, 1, 1), ease-out is cubic-bezier(0, 0, 0.58, 1) and ease-in-out is cubic-bezier(0.42, 0, 0.58, 1).
/* Snappy deceleration */
.menu {
transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
/* Overshoot and settle, like a gentle spring */
.button:hover {
transform: scale(1.1);
transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
Browser developer tools include a visual curve editor for cubic-bezier(), which makes it easy to experiment. For curves with many bounces, use linear() instead.
Interactive Demo
Syntax
cubic-bezier() = cubic-bezier( <number [0,1]>, <number>, <number [0,1]>, <number> )
Values
- x1, y1The coordinates of the first control point. x1 must be between 0 and 1; y1 can be any number.
- x2, y2The coordinates of the second control point. x2 must be between 0 and 1; y2 can be any number. y values outside 0 to 1 cause overshoot.
Example
Browser Support
The following information will show you the current browser support for the CSS cubic-bezier() function. Hover over a browser icon to see the version that first introduced support for this CSS function.
Desktop





Tablets & Mobile





