zoukankan      html  css  js  c++  java
  • FCC---Change Animation Timing with Keywords--两个小球从A都B,相同循环时间 duration, 不同的速度 speed

    In CSS animations, the animation-timing-function property controls how quickly an animated element changes over the duration of the animation.

    If the animation is a car moving from point A to point B in a given time (your animation-duration), the animation-timing-function says how the car accelerates and decelerates over the course of the drive.

    There are a number of predefined keywords available for popular options. For example, the default value is ease, which starts slow, speeds up in the middle, and then slows down again in the end.

    Other options include ease-out, which is quick in the beginning then slows down, ease-in, which is slow in the beginning, then speeds up at the end, or linear, which applies a constant animation speed throughout.

    练习题目:

    For the elements with id of ball1 and ball2, add an animation-timing-function property to each, and set #ball1 to linear, and #ball2 to ease-out.

    Notice the difference between how the elements move during the animation but end together, since they share the same animation-duration of 2 seconds.

    练习代码:

     1 <style>
     2 
     3   .balls {
     4     border-radius: 50%;
     5     background: linear-gradient(
     6       35deg,
     7       #ccffff,
     8       #ffcccc
     9     );
    10     position: fixed;
    11     width: 50px;
    12     height: 50px;
    13     margin-top: 50px;
    14     animation-name: bounce;
    15     animation-duration: 2s;
    16     animation-iteration-count: infinite;
    17   }
    18   #ball1 {
    19     left:27%;
    20     animation-timing-function: linear;
    21   }
    22   #ball2 {
    23     left:56%;
    24     animation-timing-function: ease-out;
    25   }
    26 
    27   @keyframes bounce {
    28     0% {
    29       top: 0px;
    30     }
    31     100% {
    32       top: 249px;
    33     }
    34   }
    35 
    36 </style>
    37 
    38 <div class="balls" id="ball1"></div>
    39 <div class="balls" id="ball2"></div>

    效果如下:

    注意,因为循环时间相同,所以2个小球不同速率,但同一时间结束

  • 相关阅读:
    thinkphp分页样式css代码
    thinkphp两表,多表联合查询及分页的连贯操作写法
    ThinkPHP3.2.3新特性之:数据库设置
    ThinkPHP的主从数据库配置
    CentOS7 64位下MySQL5.7安装与配置(YUM)
    sessionid如何产生?由谁产生?保存在哪里?
    GIT使用
    Windows下安装composer
    树莓派debian配置lamp[解决Apache不显示php网页]
    【Linux】Debian 下安装 Apache,MySQL,PHP
  • 原文地址:https://www.cnblogs.com/jane-panyiyun/p/11757012.html
Copyright © 2011-2022 走看看