I am using twitter bootstrap and I have glyphicon-menu-up
. When i click on the icon it collapse and expand the contents.
However when i click on the icon i want to rotate the icon by 180 degree using CSS. I know how to do it using Javascript. But i wanted to do it only using CSS.
Here is the partially working JSFiddle Demo
2
Answers
As this similar QA suggests, if you want a CSS only solution, try :active.
CSS3 transition on click using pure CSS
Your example uses JavaScript anyway to trigger the collapsed state on the div. Either way if you watch the markup from the dev console you can see that a
.collapsed
class is added to the trigger (in this case your button) when it is clicked.You can modify your current css with this to get it working:
Example