• FCC---Animate Multiple Elements at Variable Rates---还可以改循环时间,达到不同律动频率的效果


    In the previous challenge, you changed the animation rates for two similarly animated elements by altering their @keyframes rules.

    You can achieve the same goal by manipulating the animation-duration of multiple elements.

    In the animation running in the code editor, there are three "stars" in the sky that twinkle at the same rate on a continuous loop.

    To make them twinkle at different rates, you can set the animation-duration property to different values for each element.

    练习题目:

    In the previous challenge, you changed the animation rates for two similarly animated elements by altering their @keyframes rules.

    You can achieve the same goal by manipulating the animation-duration of multiple elements.

    In the animation running in the code editor, there are three "stars" in the sky that twinkle at the same rate on a continuous loop. To make them twinkle at different rates, you can set the animation-duration property to different values for each element.

    练习代码:

     1 <style>
     2   .stars {
     3     background-color: white;
     4     height: 30px;
     5     width: 30px;
     6     border-radius: 50%;
     7     animation-iteration-count: infinite;
     8   }
     9 
    10   .star-1 {
    11     margin-top: 15%;
    12     margin-left: 60%;
    13     animation-duration: 1s;
    14     animation-name: twinkle;
    15   }
    16 
    17   .star-2 {
    18     margin-top: 25%;
    19     margin-left: 25%;
    20     animation-duration: 0.9s;
    21     animation-name: twinkle;
    22   }
    23 
    24   .star-3 {
    25     margin-top: 10%;
    26     margin-left: 50%;
    27     animation-duration: 1.1s;
    28     animation-name: twinkle;
    29   }
    30 
    31   @keyframes twinkle {
    32     20% {
    33       transform: scale(0.5);
    34       opacity: 0.5;
    35     }
    36   }
    37 
    38   #back {
    39     position: fixed;
    40     padding: 0;
    41     margin: 0;
    42     top: 0;
    43     left: 0;
    44     width: 100%;
    45     height: 100%;
    46     background: linear-gradient(black, #000099, #66c2ff, #ffcccc, #ffeee6);
    47   }
    48 </style>
    49 
    50 <div id="back"></div>
    51 <div class="star-1 stars"></div>
    52 <div class="star-2 stars"></div>
    53 <div class="star-3 stars"></div>

    效果如下:

  • 相关阅读:
    【Linux技术】常用的Linux系统调用
    【Linux技术】Windows与Linux系统下的库·初探
    【C/C++】嵌入式程序员应该知道的0X10个C语言问题
    【C/C++】struct探索·extern "C"含义探索 ·C++与C的混合编程·C 语言高效编程的几招
    【Acm】八皇后问题
    【驱动】linux设备驱动·扫盲
    【驱动】linux设备驱动·字符设备驱动开发
    【教程】ubuntu下配置nvc详细教程
    【教程】InstallShield使用完全教程
    【ARM】2410裸机系列-流水灯
  • 原文地址:https://www.cnblogs.com/jane-panyiyun/p/11756928.html
Copyright © 2020-2023  润新知