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>Document</title>
  <style>
    #heart {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      width: 100px;
      height: 150px;
      /* background-color: palegreen; */
      animation: heart 1s linear 0s infinite;
    }

    #heart>span:nth-child(1) {
      position: absolute;
      width: 100px;
      height: 150px;
      background-color: peru;
      border-radius: 50px 50px 0 0;
      transform: rotate(-45deg);
      transform-origin: 0 100%;
      margin-left: 50px;
    }

    #heart>span:last-child {
      position: absolute;
      width: 100px;
      height: 150px;
      background: peru;
      border-radius: 50px 50px 0 0;
      transform: rotate(45deg);
      transform-origin: 100% 100%;
      margin-left: -50px;
    }

    @keyframes heart {
      0% {
        transform: scale(1);
      }

      50% {
        transform: scale(0.8);
      }

      100% {
        transform: scale(1);
      }
    }
  </style>
</head>

<body>
  <div id="heart">
    <span></span>
    <span></span>
  </div>
</body>

</html>

 

posted @ 2022-03-28 23:10  ascertain  阅读(29)  评论(0编辑  收藏  举报