CSS3 transition on click using pure CSS

前端 未结 6 1005
鱼传尺愫
鱼传尺愫 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条回答
  •  -上瘾入骨i
    2020-11-27 04:40

    Voila!

    div {
      background-color: red;
      color: white;
      font-weight: bold;
      width: 48px;
      height: 48px;  
      transform: rotate(360deg);
      transition: transform 0.5s;
    }
    
    div:active {
      transform: rotate(0deg);
      transition:  0s;
    }

提交回复
热议问题