• 点击旋转,再点击恢复初始状态


    今天遇到要做一个点击 + 然后开始旋转动画后变成 x    具体实现如下

    1.HTML

    <div class="box rotate"></div>                  //需要加一个初始状态

    2.CSS

    .box{                //普通样式
      width:100px;
      height:100px;
      background:skyblue;
    }
    .rotate1{             //旋转后的位置
      transform:rotate(45deg);
      transtion:all .3s linear;
      -webkit-transform:rotate(45deg);       //还是兼容一下
      -webkit-transtion:all .3s linear;
    }
    .rotate{                   //初始状态的旋转位置
      transform:rotate(0);
      transtion:all .3s linear;
      -webkit-transform:rotate(0);
      -webkit-transtion:all .3s linear;
    }

    3.JQ

    <script>
      $(function(){
        $(".box").click(function(){
         if($(this).hasClass("rotate")){
            $(this).removeClass("rotate").addClass("rotate1");
         }else{
          $(this).removeClass("rotate1").addClass("rotate");
         }
        })
      })
    </script>

    效果:

     

  • 相关阅读:
    画图软件
    万用表
    传导发射
    MOT
    Docker
    第十二章、私营部门和第三部门中的采购
    第十一章、公共部门中的采购
    第十章、部门与行业环境
    第九章、信息与通信技术系统
    第八章、组织的采购职能
  • 原文地址:https://www.cnblogs.com/zjjDaily/p/7826286.html
Copyright © 2020-2023  润新知