CSS3’s transform property is capable of applying a lot of cool effects to HTML objects. One of these cool effects is the rotating of HTML elements, which can really come in handy when trying to create unique designs or patterns with your CSS. With the transform property, any HTML object can be rotated. Let’s use the div below as an example, and say we want to rotate it by 20 degrees. Here’s how the code should look:
- transform: rotate(20deg);
Here’s what the results look like:
You can see that the square shape is now rotated on an angle. To rotate it more or less, you simply need to change the parameters that you pass through the rotate value.
You can also use the transform property to apply a 3D rotation to your HTML objects. By using rotateX, rotateY, or rotateZ instead of just ‘rotate’, you can specify which axis you’d like to rotate your HTML element along. It’s also worth noting that the transform property isn’t universally supported by all browsers, so be sure to use the appropriate prefixes with this property to ensure cross-browser compatibility!