使用css3 animation实现心跳动的效果

css实现心跳效果

直接上代码

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>test</title>
	<style type="text/css">
        .container {
            position: relative;
            margin: 100px;
        }
        .heart {
            position:relative;
            width: 100px;
            height: 100px;
            background: red;
            animation: hit .5s infinite alternate;
            transform: rotate(45deg);
        }
        .heart:before {
            position: absolute;
            left: -50px;
            content: '';
            width: 100px;
            height: 100px;
            background: red;
            border-radius: 50%;
            animation: hitLeft .5s infinite alternate;
        }
        .heart:after {
            position: absolute;
            top: -50px;
            content: '';
            width: 100px;
            height: 100px;
            background: red;
            border-radius: 50%;
            animation: hitTop .5s infinite alternate;
        }
        @keyframes hit
        {
            from { width: 100px; height: 100px; }
            to { width:150px; height: 150px; }
        }
        @keyframes hitTop {
            from { width: 100px; height: 100px; top: -50px; }
            to { width: 150px; height: 150px; top: -75px; }
        }
        @keyframes hitLeft {
            from { width: 100px; height: 100px; left: -50px; }
            to { width: 150px; height: 150px; left: -75px; }
        }
	</style>
</head>
<body>
    <div class="container">
        <div class="heart"></div>
    </div>
</body>
</html>

相关文章:

  • 2021-11-26
  • 2022-12-23
  • 2021-12-29
  • 2021-09-08
  • 2021-09-14
  • 2021-09-29
  • 2021-12-10
  • 2021-07-22
猜你喜欢
  • 2021-06-28
  • 2021-05-23
  • 2021-12-26
  • 2021-12-18
  • 2021-11-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案