CSS <transform-function> Data Type
The <transform-function> data type is one transformation, such as translate(), rotate(), scale(), skew() or matrix(), used by the transform property.
Description
The <transform-function> CSS data type represents a single transformation that changes the appearance of an element: moving, rotating, scaling, skewing or applying perspective. One or more transform functions, separated by spaces, form the value of the transform property. Transforms change only how an element is drawn; the space it takes up in the layout stays the same.
The functions fall into groups. Translation functions move an element: translate(), translateX(), translateY(), translateZ() and translate3d(). Rotation functions turn it: rotate(), rotateX(), rotateY(), rotateZ() and rotate3d(). Scaling functions resize it: scale(), scaleX(), scaleY(), scaleZ() and scale3d(). Skew functions slant it: skew(), skewX() and skewY(). Finally, matrix() and matrix3d() describe any transformation as numbers, and perspective() adds 3D depth.
The order matters: functions are applied from left to right, each one in the coordinate system produced by the previous ones. translateX(100px) rotate(45deg) moves the element and then turns it in place, while rotate(45deg) translateX(100px) turns it first and then moves it along the rotated axis, ending up somewhere else. Transforms are applied around the point set by transform-origin, which defaults to the centre. For single transformations, the individual translate, rotate and scale properties are often simpler.
Examples:
.card:hover {
transform: translateY(-4px) scale(1.02);
}
.badge {
transform: rotate(-8deg);
}
.flip {
transform: perspective(600px) rotateY(180deg);
}
Interactive Demo
Syntax
<transform-function> = <matrix()> | <matrix3d()> | <perspective()> | <rotate()> | <rotate3d()> | <rotateX()> | <rotateY()> | <rotateZ()> | <scale()> | <scale3d()> | <scaleX()> | <scaleY()> | <scaleZ()> | <skew()> | <skewX()> | <skewY()> | <translate()> | <translate3d()> | <translateX()> | <translateY()> | <translateZ()>
Values
- translate(), translateX(), translateY(), translateZ(), translate3d()Move the element along one or more axes, by <length-percentage> values (translateZ and the z value of translate3d take only lengths).
- rotate(), rotateX(), rotateY(), rotateZ(), rotate3d()Turn the element by an <angle> around an axis.
- scale(), scaleX(), scaleY(), scaleZ(), scale3d()Resize the element by <number> or <percentage> factors. Negative values mirror it.
- skew(), skewX(), skewY()Slant the element by an <angle> along one or both axes.
- matrix(), matrix3d()Describe a 2D or 3D transformation directly as a matrix of numbers.
- perspective()Sets the distance between the viewer and the z=0 plane, giving 3D transforms depth.
Example
Browser Support
The following information will show you the current browser support for the CSS transform-function data type. Hover over a browser icon to see the version that first introduced support for this CSS data type.
Desktop





Tablets & Mobile





