Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
July 21, 2021 10:52 am GMT

CSS transform : complete guide on CSS transform. Everything you need for good developer

Hello, welcome. In today's article we'll learn about CSS transform properties.

CSS transform is used to change shapes, scale the element, rotate it and much more. Let's see some transform properties.

CSS transform

Syntax
.element{    transform: value;}

This is how we use css transform. Let's see some of it's value.

Translate

Translate value is used to change element's position.

ValueDescription
translateX(px) it is used to place element in X axis
translateY(px) it is used to place element in Y axis
translateZ(px) it is used to place element in Z axis
translate(x,y) This is a short form for translateX and translateY
translate3d(x,y,z) This is a short form for translateX, translateY and translateZ
Example

Frame 1 (2)

Scale

Scale is used to scale element in x, y, z axis.

ValueDescription
scaleX(px) it is used to scale element in X axis
scaleY(px) it is used to scale element in Y axis
scaleZ(px) it is used to scale element in Z axis
scale(x,y) This is a short form for scaleX and scaleY
scale3d(x,y,z) This is a short form for scaleX, scaleY and scaleZ
Example

Translate

Rotate

Rotate value is used to rotate element's position.

ValueDescription
rotate(deg) It is used to rotate element in 2d dimension
rotateX(deg) it is used to rotate element in X axis
rotateY(deg) it is used to rotate element in Y axis
rotate3d(x,y,z) This is a short form for rotateX, rotateY and rotateZ
Example

Translate (2)

RotateX and RotateY value will behave like scale if you don't use perspective.
Use prespective property like this. For example, our HTML structure is like

<div class="parent">    <div class="element"></div></div>

Then we give CSS like this.

.parent{   perspective: 1000px;}.element{   transform: rotateX(10deg);}
Output

Translate (3)

You should give perspective property to the parent.

Skew

Skew value is used to define 2D skew transformation.

ValueDescription
skewX(deg) it is used to skew element in X axis
skewY(deg) it is used to skew element in Y axis
skew(deg) it is a short form for skewX and skewY
Example

Translate (4)

So, that's sit about CSS transform values. I hope you understood each and everything. If you have doubt or I missed some point let me know in the comments.

Articles you may found Useful

  1. CSS Positions
  2. CSS Media Query
  3. CSS flex box

And if you want to improve your webdev skills. You can watch tutorial on Disney+ clone clone by me. If you like, you can subscribe my youtube channel, and follow me on instagram. I create awesome web contents. [Subscribe], [Instagram]

Thanks For reading.


Original Link: https://dev.to/kunaal438/css-transform-everything-you-need-for-a-good-developer-4obc

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To