首页 > Web开发 > 详细

@keyframes动画和animate.css

时间:2020-02-19 21:08:12      阅读:48      评论:0      收藏:0      [点我收藏+]
 <style>
      @keyframes bounce-in {
        0%{
          transform: scale(0);
        }
        50%{
          transform: scale(1.5);
        }
        100%{
          transform: scale(1);
        }
      }
      .fade-enter-active{
        transform-origin: left center;
       animation: bounce-in 1s;
      }
      .fade-leave-active{
        transform-origin: left center;
        animation: bounce-in 1s reverse;
      }
  </style>
</head>
<body>
  <!-- 
    过程如下:
     显示  fade-enter,fade-enter-active      fade-enter-active,fade-enter-to     空
     隐藏  fade-leave,fade-leave-active      fade-leave-active,fade-leave-to     空
  -->
  <div id="root">
    <transition name=‘fade‘>
      <h1 v-show=‘show‘>
        最是年少时模样
      </h1>
    </transition>
    <button @click=‘change‘>切换</button>
  </div>
  <script>
    var vm=new Vue({
      el:#root,
      data:{
        show:true
      },
      methods:{
        change:function(){
          this.show=!this.show;
        }
      }
    })
  </script>
</body>

自定义类名:

<style>
      @keyframes bounce-in {
        0%{
          transform: scale(0);
        }
        50%{
          transform: scale(1.5);
        }
        100%{
          transform: scale(1);
        }
      }
      .active{
        transform-origin: left center;
       animation: bounce-in 1s;
      }
      .leave{
        transform-origin: left center;
        animation: bounce-in 1s reverse;
      }
  </style>
</head>
<body>
  <!-- 
    过程如下:
     显示  fade-enter,fade-enter-active      fade-enter-active,fade-enter-to     空
     隐藏  fade-leave,fade-leave-active      fade-leave-active,fade-leave-to     空
  -->
  <div id="root">
    <transition name=‘fade‘ 
      enter-active-class=‘active‘
      leave-active-class=‘leave‘
    >
      <h1 v-show=‘show‘>
        最是年少时模样
      </h1>
    </transition>
    <button @click=‘change‘>切换</button>
  </div>
  <script>
    var vm=new Vue({
      el:#root,
      data:{
        show:true
      },
      methods:{
        change:function(){
          this.show=!this.show;
        }
      }
    })
  </script>
</body>

animate.css使用:

  <script src="./node_modules/vue/dist/vue.js"></script>
  <link rel=‘stylesheet‘ type="text/css" href="./animate.css">
</head>
<body>
  <!-- 
    过程如下:
     显示  fade-enter,fade-enter-active      fade-enter-active,fade-enter-to     空
     隐藏  fade-leave,fade-leave-active      fade-leave-active,fade-leave-to     空
  -->
  <div id="root">
    <transition name=‘fade‘ 
      enter-active-class=‘animated tada‘
      leave-active-class=‘animated rubberBand‘
    >
      <h1 v-show=‘show‘>
        最是年少时模样
      </h1>
    </transition>
    <button @click=‘change‘>切换</button>
  </div>
  <script>
    var vm=new Vue({
      el:#root,
      data:{
        show:true
      },
      methods:{
        change:function(){
          this.show=!this.show;
        }
      }
    })
  </script>
</body>

 

@keyframes动画和animate.css

原文:https://www.cnblogs.com/em2464/p/12333032.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!