跳动的心,简单的动画特效,希望大家都能在前端这个工作中继续跳动下去

153 阅读1分钟

学习最重要的是有趣,喜欢每一代码出来的效果,也希望能够在前端的岗位站稳脚步 此篇文章仅献给每一个迷茫的人,加油,生活的美好你我同在 ^v^ 每天都是开心的每一天

    • 简单的动画特效,希望大家都能在前端这个工作中继续跳动下去 - -
<!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 {
      position: relative;
      margin: 200px auto;
      width: 200px;
      height: 200px;
      background-color: red;
      transform: rotate(45deg) scale(.5);
      border-radius: 0 0 15px 0;
      animation: donghua 2s infinite;
    }

    .box::after {
      position: absolute;
      top: 0;
      left: 0;
      width: 200px;
      height: 200px;
      background-color: red;
      border-radius: 50%;
      content: '';
      transform: translateX(-100px);
    }

    .box::before {
      position: absolute;
      top: 0;
      right: 0;
      width: 200px;
      height: 200px;
      border-radius: 50%;
      background-color: red;
      transform: translateY(-100px);
      content: '';
    }

    @keyframes donghua {
      25% {
        transform: rotate(45deg) scale(1);
      }

      50% {
        transform: rotate(45deg) scale(.5);
      }

      75% {
        transform: rotate(45deg) scale(1);
      }

      100% {
        transform: rotate(45deg) scale(.5);
      }
    }
  </style>
</head>

<body>
  <div class="box">

  </div>
</body>

</html>