In CSS, the transform property is used to change the coordinate space of an element, with transform property effects like rotate, skew, and translate being added to an element. Transform helps to design elements that improve user interaction with the webpage.
.element{
background-color:transparent;
width:300px;
float: left;
transform: rotateY(180deg);
}
Transform Syntax
transform: rotateY(angle);
When using CSS 3D flip, transform takes one function either rotateY() or rotateX() each of these functions has one parameter angle e.g 180deg, that determines what degree the element should rotate. The parameter specifies the angle of the rotation, the parament can be a positive number or negative number.
A positive number will result in a clockwise rotation and a negative value result in a counter-clockwise rotation
rotateY();
rotateY() function rotates an element around the y-axis when used with the CSS transform property. the function value can be positive to rotate the element clockwise or negative to rotate the element counter-clockwise on a y-axis direction as shown below:
.element{
background-color:transparent;
width:300px;
height: 400px;
transform: rotateY(-100deg);
}
This will rotate the element 100 degrees in counter-clockwise direction on the y-axis direction.
rotateX()
The rotateX() function is used with CSS 3D-transforms. It's used with transform property to rotate an element around the x-axis. It can be used along with rotateY() to rotate the element around the y-axes when needed.
.element{
background-color:transparent;
width:300px;
height: 400px;
transform: rotateX(180deg);
}
The above code will rotate the element 180 degrees in a clockwise direction on the x-axis direction.
transform: rotateY(180deg);
rotateY();
rotateX();
Top comments (0)