CSS3 transition on click using pure CSS

前端 未结 6 1022
鱼传尺愫
鱼传尺愫 2020-11-27 04:04

I\'m trying to get an image (a plus symbol) to rotate 45 degrees to create a cross symbol. I have so far managed to achieve this using the code below but its working on hove

6条回答
  •  我在风中等你
    2020-11-27 04:36

    As jeremyjjbrow said, :active pseudo won't persist. But there's a hack for doing it on pure css. You can wrap it on a tag, and apply the :active on it, like this:

    
        Cross Menu button
     
    

    And the css:

    .test:active .crossRotate {
        transform: rotate(45deg);
        -webkit-transform: rotate(45deg);
        -ms-transform: rotate(45deg);
        }
    

    Try it out... It works (at least on Chrome)!

提交回复
热议问题