animation动画

animation 属性 
  animation 用来设置动画的名称、执行时间等。
  animation-name:动画名称。
  animation-duration:动画执行时间。
  animation-iteration-count:动画执行次数,infinite -- 一直执行。
  animation-fill-mode:动画执行之前或之后的效果是否可见,forwards -- 动画执行完之后不会变成原来的效果。
  animation-delay:动画延迟执行的时间。
  animation-direction:动画下一次执行的顺序,alternate -- 奇数次正向播放,偶数次反向播放;reverse -- 反向播放;alternate-reverse -- 奇数次反向播放,偶数次正向播放。
  animation-timing-function:动画执行的速度曲线,ease-in -- 缓慢开始,ease-out -- 缓慢结束,ease-in-out -- 缓慢开始缓慢结束。
  animation 是一个复合属性,依次是:名称、时间、执行次数、动画之前或之后的效果是否可见、延迟时间、播放顺序、速度曲线。
@keyframes 属性用来设置具体的动画
  语法:@keyframes 动画名 { from(开始){ css效果 } to(结束){ css效果 } }
  也可以:@keyframes 动画名 { 25%{ css效果 } 50%{ css效果 } 75{ css效果 } }
复制代码
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>动画</title>
  <style>
    body {
      background: #555;
    }

    .box {
      background: cyan;
      width: 200px;
      height: 200px;
      /* 动画名称 */
      animation-name: anima1;
      /* 动画执行时间 */
      animation-duration: 3s;
      /* 动画执行次数   infinite是一直执行 */
      animation-iteration-count: infinite;
      /* 动画执行之前或之后的效果是否可见   forwards:动画执行完之后不会变成原来的效果 */
      animation-fill-mode: forwards;
      /* 动画的延迟执行时间 */
      /* animation-delay: 1s; */
      /* 动画下一次执行的顺序。alternate指的是奇数次正向播放,偶数次反向播放 */
      /* reverse:反向播放 */
      /* alternate-reverse:奇数次反向播放,偶数次正向播放 */
      animation-direction: alternate-reverse;
      /* 速度曲线 */
      /* ease-in:缓慢开始  ease-out:缓慢结束  ease-in-out:缓慢开始缓慢结束 */
      animation-timing-function: ease-in-out;
      position: relative;
      /* animation: 名称  时间  执行次数  动画之前或之后的效果是否可见  延迟时间  播放顺序  速度曲线; */
    }

    /* 动画 */
    @keyframes anima1 {

      /* 开始 */
      from {
        width: 200px;
        background: red;
        top: 0;
        left: 0;
      }

      /* 结束 */
      to {
        width: 600px;
        background: cyan;
        top: 200px;
        left: 100px;
      }
    }
  </style>
</head>

<body>
  <div class="box"></div>
</body>

</html>
复制代码
复制代码
<style>
    body {
      background: #555;
    }

    .box {
      background: #fff;
      width: 200px;
      height: 200px;
      position: relative;
      top: 0;
      left: 0;
      animation: anima1 5s infinite forwards ease-in-out;
    }

    /* 动画 */
    @keyframes anima1 {
      25% {
        top: 0;
        left: 300px;
        background: red;
        border-radius: 50% 0 0 0;
      }

      50% {
        top: 300px;
        left: 300px;
        background: cyan;
        border-radius: 0 50% 0 0;
      }

      75% {
        top: 300px;
        left: 0%;
        background: gray;
        border-radius: 0 0 50% 0;
      }

      100% {
        top: 0;
        left: 0;
        border-radius: 0 0 0 50%;
      }
    }
  </style>
复制代码

 

posted @   守鹤  阅读(1696)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示