CSS Transforms

Please Share On:

In this tutorial, We will learn 2D and 3D CSS transforms which allow you to rotate, move, scale, and screw elements.

2D Transforms

Here are the list of CSS properties that can use in 2d transform.

FunctionsSyntaxDefinitionExample
translate(x,y)transform: translate(50px,40px);Move an element along the x-axis and y-axis from its current positionTry it
translateX(n)transform: translateX(50px);Move an element along the x-axis onlyTry it
translateY(n)transform: translateY(50px);Move an element along the y-axis onlyTry it
rotate(angle)transform: rotate(10deg);Rotate an element at a defined angleTry it
scale(x,y)transform: scale(1.5,2);Change the element width and heightTry it
scaleX(n)transform: scaleX(2);Change the element width onlyTry it
scaleY(n)scaleX(n)Change the element height onlyTry it
skewX(angle)transform: skew(10deg, 20deg);Skew transformation along x-axis and y-axisTry it
skewX(angle)transform: skewX(50deg);Skew transformation along x-axisTry it
skewY(angle)transform: skewY(50deg);Skew transformation along y-axisTry it
matrix(n,n,n,n,n,n)transform: matrix(2, 0.5, 0, 1, 2, 0);It combines all 2D transform methods into one.Try it


3D Transforms

In CSS, you can define any elements into 3D views by applying the z-axis. 2D transforms use x-axis and y-axis whereas 3D transforms apply the z-axis also.

Here are the list of CSS properties that can use in 3D transform.

FunctionsSyntaxDefinitionExample
translate3d()transform: translateX(50px, 50px, 50px);Move an element along into x-axis, y-axis and z-axis from its current positionTry It
translateX(x)transform: translateX(50px);Move an element along the x-axis onlyTry It
translateY(y)transform: translateY(50px);Move an element along the y-axis onlyTry It
translateZ(z)transform: translateZ(50px);Move an element along the z-axis onlyTry It
rotate3d(x,y,z,angle)transform: rotate3d(1, 1, 1, 45deg);Rotate an element along inn 3D axis.Try It
rotateX(angle)transform: rotateZ(90deg);Rotate an element along in x-axis.Try It
rotateY(angle)transform: rotateY(180deg);Rotate an element along in y-axis.Try It
rotateZ(angle)transform: rotateZ(90deg);Rotate an element along in z-axis.Try It
scale3d(x,y,z)transform: scale3d(2,2,2);Define a 3D scale transformationTry It
scaleX(x)transform: scaleX(2);Define an x-axis scale transformationTry It
scaleY(y)transform: scaleY(2);Define an y-axis scale transformationTry It
scaleZ(z)transform: scaleZ(2);Define an z-axis scale transformationTry It
perspective(n)perspective(n)Define a prespective view for a 3D transformationTry It
matrix3d
(n,n,n,n,n,n,n,n,n,n,n,n,n,n,n,n)
matrix3d
()
Define a 3D tranformation using 4×4 matrix of 16 valuesTry It



You may be interested in the following topics:

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright @2023. All Right Reserved.


Social media & sharing icons powered by UltimatelySocial