rotate() function
The rotate() function is an inbuilt function that is used to rotate an element based on the given angle as an argument. The angle can be set in terms of degrees, gradians, radians, or turns.
Syntax:
transform: rotate(90deg);
Example: Implementation of the transform rotate property
HTML
<!DOCTYPE html> < html > < head > < style > body { text-align: center; margin-top: 100px; } .rotate-image { /* Adjust the angle as needed */ transform: rotate(45deg); margin-top: 100px; } </ style > </ head > < body > < h1 style = "color: green;" > w3wiki </ h1 > < h3 > Using transform: rotate() Property </ h3 > < img src = "https://media.w3wiki.org/wp-content/cdn-uploads/20190710102234/download3.png" alt = "Rotated Image" class = "rotate-image" > </ body > </ html > |
Output:
How to Rotate Image in HTML ?
In this article, we will see how to rotate images in HTML. To change the orientation of an image in HTML, you can utilize the CSS property called “transform” along with the “rotate” function. This property, when applied to the image element, enables you to specify the rotation angle (e.g., “transform: rotate(90deg);” for a 90-degree rotation). Simply adjust the angle as required to achieve the desired rotation effect.
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.
Table of Content
- rotate() function
- scaleX() function
- scaleY() function