CSS3 transforms, we can move, scale, reverse, rotate, and extrude elements.
Conversion
In this chapter you will learn about the 2D transformation method:
- Translate ()
- Rotate ()
- Scale ()
- Skew ()
- Matrix ()
<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"> <title>Beginner's Tutorial (runoob.com)</title> <style>Div{width:200px;Height:100px;Background-color:Yellow; /*Rotate Div*/Transform:Rotate (30deg);-ms-transform:Rotate (30deg); /*IE 9*/-webkit-transform:Rotate (30deg); /*Safari and Chrome*/}</style></Head><Body><Div>Hello</Div></Body></HTML>
Translate () method
The translate () method moves from the current element position according to the parameters given at the left (x-axis) and top (Y-axis) positions.
Div{transform:translate (50px,100px);-ms-transform:translate (50px,100px);/* IE 9 */-webkit-transform:translate ( 50px,100px); /* Safari and Chrome */}
The Translate value (50px,100px) is a 50 pixel move from the left element and 100 pixels from the top.
Rotate () method
The rotate () method rotates the element clockwise in a given degree. Negative values are allowed so that the elements are rotated counterclockwise.
Div{transform:rotate (30deg);-ms-transform:rotate (30deg);/* IE 9 */-webkit-transform:rotate (30DEG);/* Safari and CHRO Me */}
The Rotate value (30deg) element rotates 30 degrees clockwise.
Scale () method
The scale () method, which increases or decreases the size of the element, depends on the width (x-axis) and height (y-axis) parameters:
div { margin:150px; width:200px; height:100px; Background-color:yellow; border:1px solid black; border:1px solid black; -ms-transform:scale (2,3); /* IE 9 * /-webkit-transform:scale (2,3);/* Safari * /Transform:scale (2,3);/* Standard syntax */}
The scale (2,3) transition width is twice times the original size, and its original size is 3 times times the height.
Skew () method syntax
Transform:skew (<angle> [<angle>]);
Contains two parameter values that represent the angle of the x-axis and y-axis skew, and if the second parameter is empty, the default is 0, and the parameter is a negative representation that tilts in the opposite direction.
- Skewx (<angle>); indicates that only the x-axis (horizontal direction) is tilted.
- Skewy (<angle>); indicates that only the y-axis (vertical direction) is tilted.
<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"> <title>Beginner's Tutorial (runoob.com)</title> <style>Div{width:100px;Height:75px;Background-color:Red;Border:1px solid Black;}Div#div2{Transform:skew (30deg,20deg);-ms-transform:skew (30deg,20deg); /*IE 9*/-webkit-transform:skew (30deg,20deg); /*Safari and Chrome*/}</style></Head><Body><Div>Hello. This is a DIV element.</Div><DivID= "Div2">Hello. This is a DIV element.</Div></Body></HTML>
CSS3 2D Conversion