![]() |
VOOZH | about |
Rotating and scaling images in HTML can enhance the visual presentation of your web content. By using CSS properties like transform, you can easily change the orientation and size of images. This will help you understand the process of rotating images using the rotate() function and scaling images with the scaleX() and scaleY() functions.
To rotate an image in HTML, you can use the transform: rotate() property. This property allows you to change the orientation of an image by a specified angle, measured in degrees, gradians, radians or turns.
Note: To rotate by 90 degrees any of the units can be used with their corresponding values. 90 degrees would equal 100 gradients or 0.25 turns.
transform: rotate(90deg);Example: Implementation of the transform rotate property
Output:
👁 Screenshot-2023-12-20-102619
In addition to rotating, you can also scale images along the x-axis and y-axis using the scaleX() and scaleY() functions.
The scaleX() function is an inbuilt function which is used to resize an element along the x-axis in a 2D plane. It scales the elements in a horizontal direction.
transform : scaleX( number )
// number is scalling factor
Example: Implementation of the transform scaleX( ) property
Output:
👁 Screenshot-2023-12-20-104154
The scaleY( ) function is an inbuilt function which is used to resize an element along the y-axis in a 2D plane. It scales the elements in a vertical direction.
transform: scaleY(scalingFactor);
Example: Implementation of the transform scale( ) property with an example.
Output: