头一次尝试css3的动画

<!DOCTYPE html>
<html lang="zh-cn">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>animation</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    .gun {
      position: relative;
      display: inline-block;
      width: 300px;
      height: 240px;
      background: url("img/gun.webp");
      z-index: 1;
    }

    .box {
      position: relative;
      display: inline-block;
      width: 40px;
      height: 20px;
      border-radius:  0 20px 20px 0;
      background-color: orange;
      top: -146px;
      left: -50px;
      z-index: 0;
      animation: move 10s linear;
      animation-iteration-count: infinite;
      animation-play-state: paused;
    }

    body:hover .box {
      animation-play-state: running;
    }

    body:hover .people {
      animation-play-state: running;
    }

    .people {
      width: 60px;
      height: 60px;
      background-color: #f1f1f1;
      font-size: 14px;
      line-height: 60px;
      position: relative;
      left: 250px;
      top: -4px;
      transition-delay: 9s;
      transition-duration: 1s;
      text-align: center;
    }

    .people p {
      transform: scale(.6);
    }

    body:hover .people {
      width: 120px;
      height: 120px;
      border-radius: 50%;
      background-color: pink;
      line-height: 120px;
    }

    @keyframes move {
      /* 出枪 */
      30% {
        transform: translateX(1200px);
      }
      /* 第一次拐弯 */
      50% {
        transform: translateX(1200px) rotate(90deg);
      }

      60% {
        transform: translate(1200px,300px) rotate(90deg);
      }

      /* 第二次拐弯 */
      70% {
        transform: translate(1200px, 300px) rotate(180deg);
      }

      80% {
        transform: translate(0, 300px) rotate(180deg);
      }
      /* 回来 */

      90% {
        transform: translate(0, 300px) rotate(270deg);
      }
      100% {
        transform: translate(0) rotate(270deg);
      }
    }

  </style>
</head>

<body>
  <div class="gun"></div>
  <div class="box"></div>
  <div class="people">
    <p>子弹拐弯</p>
  </div>
</body>

</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值