css3动画特效

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>
    /* 设定图像 */
    .box {
      width: 100px;
      height: 100px;
      background-color: lightblue;
      border-radius: 50%;
    }

    .move {
      /* 2. 设定动画 */
      /* animation-name: move;
      animation-duration: 2s;
      animation-timing-function: linear;
      animation-fill-mode:forwards;   
      animation-iteration-count: 2; 
      animation-direction: alternate-reverse;    */

      /* 动画的书写形式 */
      animation: move 2s 1s linear 2 forwards;
    }

    /* 第一个图像的触动动画 */
    .move:hover {
      animation-play-state: paused;
    }

    /* 第二个图像的动画延迟一秒  */
    .move_delay_1 {
      animation-delay: 1s;
    }

    /* 1. 定义动画帧 */
    @keyframes move {
      from {
        margin-left: 0;
      }

      to {
        margin-left: 800px;
      }
    }
  </style>
</head>

<body>
  <!-- 第一个图像 -->
  <div class="box move"></div>
  <!-- 第二个图像延迟 -->
  <div class="box move move_delay_1"></div>
</body>

</html>

运行结果:

 

 

过渡与变形:

<!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>
    .box {
      width: 300px;
      height: 300px;
      background-color: lightcoral;
      cursor: pointer;
      margin: 100px auto;
      /* 过渡与变化的结合 */
      transition: transform, background-color 2s, 2s 0s linear;
    }

    .box:hover {
      background-color: #f4f4f4;
      transform: scale(1.2);
    }
  </style>
</head>

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

</html>

运行结果:

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值