zoukankan      html  css  js  c++  java
  • 移动端----切入切出动画

    <!DOCTYPE html>
    <html>
    <head>
      <meta charset="utf-8">
      <meta content="width=device-width, initial-scale=1, user-scalable=no, minimal-ui" name="viewport">
      <meta name="apple-mobile-web-app-capable" content="yes">
      <meta name="apple-mobile-web-app-status-bar-style" content="black">
      <meta content="telphone=no" name="format-detection">
      <title>切入切出动画</title>
      <link media="all" href="http://www.w3cplus.com/mcommon/reset.css" rel="stylesheet">
      <style type="text/css">
      .demo{ background-color: #333; height: 300px; width: 800px; margin: 0 auto;}
        .demo2{ background-color: #333; height: 300px; width: 800px; margin:10px auto;}
     .left-in, .left-out {
      -webkit-animation-duration: 1s;
      animation-duration: 1s;
      -webkit-animation-fill-mode: both;
      animation-fill-mode: both;
    }
    
    @-webkit-keyframes left-in {
      0% {
        -webkit-transform: translate3d(-2000px, 0, 0);
      }
    
      100% {
        -webkit-transform: translate3d(0, 0, 0);
      }
    }
    @keyframes left-in {
      0% {
        transform: translate3d(-2000px, 0, 0);
      }
    
      100% {
        transform: translate3d(0, 0, 0);
      }
    }
    .left-in {
      -webkit-animation-name: left-in;
      animation-name: left-in;
    }
    
    @-webkit-keyframes left-out {
      0% {
        -webkit-transform: translate3d(0, 0, 0);
      }
    
      100% {
        -webkit-transform: translate3d(-2000px, 0, 0);
      }
    }
    @keyframes left-out {
      0% {
        transform: translate3d(0, 0, 0);
      }
    
      100% {
        transform: translate3d(-2000px, 0, 0);
      }
    }
    .left-out {
      -webkit-animation-name: left-out;
      animation-name: left-out;
    }
    
    
      </style>
    </head>
    <body>
       <div class="demo left-in"></div>
       <div class="demo2 left-out"></div>
    </body>   
    </html>

    transition动画与animation动画的区别在于:

    1、transition动画只能定义开始和结束位置,中间无法定义;而keyframes则可以定义n帧作为中间的过渡帧

    2、对于切入切出动画来说,transition动画我们只需添加删除一个class即可完成,而animation动画则需要切换两个class,再在最后删除class,比较复杂。

    3、如果你的动画不需要定制中间帧,那直接使用transition动画即可,切换一个class就可以了,运动结束时候可以js调用transitionend函数,而如果需要定制中间帧,那么还是animation,当然animation的事件有三个animationstart,animationiteration,animationend

    原文链接:http://www.w3cplus.com/mobile/mobile-terminal-refactoring-slider-animation.html

  • 相关阅读:
    nginx不支持pathinfo模式解决方法
    php只保留两位小数
    分享图文到QQ空间
    android 使用信鸽推送通知栏不显示推送的通知?
    Editetext获取焦点后让输入软键盘中出现搜索按键
    Android EditText的使用过程中遇到的问题
    在线根据现有apk生成指定id的推广apk (已过时)
    @Validated和@Valid区别
    idea快捷键使用总结
    大概
  • 原文地址:https://www.cnblogs.com/webfby/p/4362182.html
Copyright © 2011-2022 走看看