zoukankan      html  css  js  c++  java
  • 动画

    一、基本使用

    首先要定义动画的名字,然后通过name属性应用。duration表示这个动画效果持续的时间。如果不指定animation-duration 属性,则动画不会发生,因为默认值是 0s(0秒)。

    定义的动画主要是由动画序列组成。比如做一个div块,让他在页面加载的时候x轴从0px移到1000px,代码如下:

    <div class="box"></div>
    @keyframes move {
      0% {
        transform: translateX(0px);
      }
      100% {
        transform: translateX(1000px);
      }
    }
    .box{
      width: 200px;
      height: 200px;
      background: pink;
      animation-name: move;
      animation-duration: 2s;
    }

     二、动画序列

    上面的百分比,也可以换成from和to。from表示0%,to表示100%,这就是keyframe,动画序列。

    做一个简单的动画,让一个方块不的顺时针移动,当鼠标放到方块上时, 方块停止移动,鼠标离开,再移动。

    难点:鼠标经过暂停,使用 animation-play-state: paused属性

    效果图:

    代码:

    .container .animation{
       200px;
      height: 200px;
      border: 1px solid #000;
      @keyframes action {
        0% {
          transform:translate(0,0);
        }
        25%{
          transform: translate(100px, 0px);
        }
        50% {
          transform: translate(100px, 100px);
        }
        75%{
          transform: translate(0, 100px);
        }
        100%{
          transform: translate(0, 0);
        }
      }
      .box{
         100px;
        height: 100px;
        background: pink;
        animation: action 2s ease 0s infinite forwards;    
      }
      .box:hover {
        animation-play-state: paused;
      }
    }
    

     

    三、动画简写顺序 

    animation: name duration timing-function delay iteration-count direction fill-mode;
    注意:
    (1)animation-duration 属性定义需要多长时间才能完成动画。如果未指定 animation-duration 属性,则动画不会发生,因为默认值是 0s(0秒)。
    (2)animation-direction 属性指定是向前播放、向后播放还是交替播放动画。

     (3)animation-fill-mode : none | forwards | backwards | both;

     

     

     四、实际应用-做一个大数据地点光圈图

    效果图:

    难点:

    代码:

      <div class="animation">
          <div class="mark"></div>
          <div class="ripple1"></div>
          <div class="ripple2"></div>
          <div class="ripple3"></div>
        </div>
    .container .animation{
      position: relative;
      width: 200px;
      height: 200px;
      border: 1px solid #000;
      .mark {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 8px;
        height: 8px;
        background:  #2277e4;
        border-radius: 50%;
      }
      div[class^="ripple"]{
        position: absolute;
        top:50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 20px;
        height: 20px;
        border-radius: 50%;
        box-shadow: 0 0 10px  #2277e4;
        animation: rippleMove 1.2s linear 0s infinite; 
      }
      .ripple2{
        animation-delay: 0.6s !important;
        
      } .ripple3{
        animation-delay: 1.1s !important;
      }
      @keyframes rippleMove{  
        75%{
          width: 40px;
          height: 40px;
          opacity: 0.4;
        }
        100% {
          width: 50px;
          height: 50px;
          opacity: 0.1;
        }
      }
    }
  • 相关阅读:
    性能测试中的二八原则
    OS + Linux Shell Programme / 100 cases
    db postgres openGauss
    OS + Linux sshkeygen / sshcopyid / id_rsa / id_rsa.pub / authorized_keys
    OS + Android performance matrix / memory LeakCanary
    springBoot 使用ConfigurationProperties+PropertySource注解 引入yml配置文件
    SpringBoot2.0集成WebSocket,实现后台向前端推送信息
    springBoot + rabbitMQ +手动确认消息 + 控制(接口、定时任务)消费者上下线
    linux 环境下安装keepalived 并且进行简单的主备配置
    eureka 注册列表低延迟注册、剔除服务配置 实现8s延迟
  • 原文地址:https://www.cnblogs.com/qingshanyici/p/14710613.html
Copyright © 2011-2022 走看看