Using CSS transforms, transitions and animation, we can rotate any element on the page, but CSS won’t allow us to do that dynamically, in response to user input. To make that happen, we need JavaScript, combined with the lessons I’ve shown to this point regarding CSS rotation.
Full article