用前端代码写一个会动的爱心
时间: 2023-11-10 18:34:15 浏览: 36
我可以帮你写一个会动的爱心,用HTML和CSS来实现:
<style>
.heart {
position: relative;
width: 100px;
height: 90px;
background: #000;
animation: beat 1s infinite;
}
.heart:before, .heart:after {
position: absolute;
content: "";
left: 50px;
top: 0;
width: 50px;
height: 80px;
background: #000;
border-radius: 50%;
transform: rotate(-45deg);
transform-origin: 0 100%;
}
.heart:after {
left: 0;
transform: rotate(45deg);
transform-origin: 100% 100%;
}
@keyframes beat {
0% {
transform: scale(1);
}
20% {
transform: scale(1.2);
}
40% {
transform: scale(1);
}
}
</style>
<div class="heart"></div>
阅读全文