css心动案例——源自b战
实现效果
2022-08-19-11-33-20
HTML
<body>
<div class="heart"></div>
</body>
CSS
* {
padding: 0;
margin: 0;
}
body {
background: rgb(20, 69, 69);
}
.heart {
width: 200px;
height: 200px;
background: red;
margin: 200px auto;
transform: rotate(45deg) scale(0.5);
animation-name: dh;
animation-duration: 5s;
animation-iteration-count: infinite;
}
.heart::before {
content: '';
width: 200px;
height: 200px;
border-radius: 50%;
position: absolute;
background: red;
transform: translateX(-100px);
}
.heart::after {
content: '';
width: 200px;
height: 200px;
border-radius: 50%;
position: absolute;
background: red;
transform: translateY(-100px);
}
@keyframes dh {
25% {
transform: rotate(45deg) scale(1);
}
50% {
transform: rotate(45deg) scale(0.5);
}
75% {
transform: rotate(45deg) scale(1);
}
to {
transform: rotate(45deg) scale(0.5);
}
}
其中,心形由一个正方形和两个圆形旋转重叠组成