Rotate element with TailwindCSS
Question:
How to rotate element with TailwindCSS? Answer:
<div class="w-40 h-10 bg-sky-100 hover:rotate-6">Rotate on hover</div>
Description:
You can rotate an element with TailwindCSS using the rotate-{degree}
utility class. You can use the predefined values or any custom value with arbitrary values.
To create a nice rollover rotation with a small animation you can use the following code:
<div class="flex">
<div class="w-40 h-10 bg-sky-100 m-2 hover:rotate-[-6deg] transition-all duration-500">Item 1</div>
<div class="w-40 h-10 bg-sky-100 m-2 hover:rotate-[-6deg] transition-all duration-500">Item 2</div>
</div>
Where the result is:
Reference:
TailwindCSS rotate reference
Share "How to rotate element with TailwindCSS?"
Related snippets:
Tags:
rotate, element, 90, 45 degrees, tailwind Technical term:
Rotate element with TailwindCSS