css-animation animation realizes the beating heart

css-animation animation realizes the beating heart

1. Heart structure: two circles and a square

Please add a picture description

2. Through the rotation and scaling of transform and animation animation, the heart beats. The html code is as follows
<!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>
        * {
      
      
            padding: 0;
            margin: 0;
        }

        body {
      
      
            padding: 20vw;
        }

        .love {
      
      
            width: 6vw;
            height: 6vw;
            background-color: red;
            transform: rotate(45deg);
            box-shadow: 0 0 1.5vw 0 red;
            animation: pengpeng 1s infinite;
        }

        .love::after,
        .love::before {
      
      
            content: '';
            width: 6vw;
            height: 6vw;
            border-radius: 50%;
            position: absolute;
            background-color: red;
            box-shadow: 0 0 1.2vw 0 red;
        }

        .love::after {
      
      
            right: 2.8vw;
        }

        .love::before {
      
      
            top: -2.8vw;
        }

        @keyframes pengpeng {
      
      
            0% {
      
      
                transform: rotate(45deg) scale(0.9);
            }

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

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

<body>
    <div class='love'></div>
</body>

</html>

heart

Guess you like

Origin blog.csdn.net/weixin_46724655/article/details/124837867