The transform property in CSS is used to perform geometric transformations on elements, including translation, scaling, rotation, and tilt. Its usage includes: translation: translateX(x)/translateY(y)/translate(x, y) scaling: scaleX(x)/scaleY(y)/scale(x, y) rotation: rotate(angle)/rotateX(angle )/rotateY(angle)/rotateZ(angle) skew: skewX(angle)/skewY(angle)
Transform usage in CSS
The transform property is used to perform geometric transformations on elements in CSS, including translation, scaling, rotation, and skew. It provides powerful features to create various visual effects such as animation, morphing and distortion.
Usage
The syntax of the transform attribute is as follows:
<code class="css">transform: <transform-function> [<transform-function>]...;</code>
Among them, <transform-function>
can be any of the following Transformation function:
translateX(x)
: Translate the element along the x-axis translateY(y)
: Translate the element along the y-axis translate(x, y)
: Translate the element along the x and y axes scaleX(x)
: Scale the element along the x axisscaleY(y)
: Scale the element along the y axis scale(x, y)
: Scale the element along the x and y axesrotate(angle)
: Rotate the element by an angle rotateX(angle)
: Rotate the element along the x-axis rotateY( angle)
: Rotate the element along the y-axis rotateZ(angle)
: Rotate the element along the z-axis skewX(angle)
: Skew elements along the x-axisskewY(angle)
: Skew elements along the y-axisMultiple transformations
## The #transform attribute can combine multiple transformation functions, separated by spaces:<code class="css">transform: translate(50px, 100px) rotate(45deg) scale(2);</code>
Combined units
transform value can include pixels (px), percentage (%) or other CSS units.Apply to elements
The transform attribute can be applied to any HTML element, but is typically used to create animations and visual effects, for example:Note
The above is the detailed content of How to use transform in css. For more information, please follow other related articles on the PHP Chinese website!