One of the most overlooked features of CSS transitions is the ability to specify a cubic-bezier transition.  For most projects the standard: ease, ease-in, ease-out, ease-in-out, and linear will do.

If you want your CSS animations to attain to another level or perhaps create a very specific (custom) effect, you should learn the basics of cubic-bezier (CSS) and the Cubic Bezier Curve.

Cubic Bezier Curve (definition):

Four points P0, P1, P2 and P3 in the plane or in higher-dimensional space define a cubic Bézier curve. The curve starts at P0 going toward P1 and arrives at P3 coming from the direction of P2. Usually, it will not pass through P1 or P2; these points are only there to provide directional information. The distance between P0 and P1 determines “how far” and “how fast” the curve moves towards P1 before turning towards P2.

Writing BPi,Pj,Pk(t) for the quadratic Bézier curve defined by points Pi, Pj, and Pk, the cubic Bézier curve can be defined as a linear combination of two quadratic Bézier curves:

\mathbf{B}(t)=(1-t)\mathbf{B}_{\mathbf P_0,\mathbf P_1,\mathbf P_2}(t) + t \mathbf{B}_{\mathbf P_1,\mathbf P_2,\mathbf P_3}(t) \mbox{ , } 0 \le t \le 1.

The explicit form of the curve is:

\mathbf{B}(t)=(1-t)^3\mathbf{P}_0+3(1-t)^2t\mathbf{P}_1+3(1-t)t^2\mathbf{P}_2+t^3\mathbf{P}_3 \mbox{ , } 0 \le t \le 1.

For some choices of P1 and P2 the curve may intersect itself, or contain a cusp.

Any series of any 4 distinct points can be converted to a cubic Bézier curve that goes through all 4 points in order. Given the starting and ending point of some cubic Bézier curve, and the points along the curve corresponding to t = 1/3 and t = 2/3, the control points for the original Bézier curve can be recovered.


CSS implementation:

Use the property “transition”,  with the value “cubic-bezier(n,n,n,n)”.  Possible values are numeric values from 0 to 1.

Written out (example) syntax:

#example {transition: 600ms cubic-bezier(0.83,0.22,0.8,1.31);}

Demo (hover)

Note the little bounce at the end.  That’s created by the last parameter of 1.31 that extends breifly past the normal numeric value (limit) of 1.  Again, a simple example of creating a unique and fine tuned animation. If you would like to get your hands a little dirty and experiment on your own, I would recommend heading over to