<style>
* {
margin: 0;
padding: 0;
}
body {
width: 100vw;
height: 100vh;
background-color: #34495e;
display: flex;
justify-content: center;
align-items: center;
}
.heart {
width: 200px;
height: 200px;
background: #e74c3c;
transform: rotate(45deg) scale(.5);
animation-name: hd;
animation-duration: 2s;
animation-iteration-count: 4;
opacity: 0.5;
}
.heart::before {
content: '';
width: 200px;
height: 200px;
border-radius: 50%;
position: absolute;
background: #e74c3c;
transform: translateX(-100px);
}
@keyframes hd {
25% {
opacity: 1;
transform: rotate(45deg) scale(1);
}
50% {
opacity: 0.5;
transform: rotate(45deg) scale(.5);
}
75% {
opacity: 1;
transform: rotate(45deg) scale(1);
}
85% {
opacity: 0.5;
transform: rotate(45deg) scale(.5);
}
to {
opacity: 1;
transform: rotate(45deg) scale(1);
}
}
.heart::after {
content: '';
width: 200px;
height: 200px;
border-radius: 50%;
position: absolute;
background: #e74c3c;
transform: translateY(-100px);
}
</style>
</head>
<body>
<div class="heart">
</div>
</body>
视频学习:【香香的干货】这么牛X的css3 animation动画,你会用了吗?css 前端开发工程师必学干货分享_哔哩哔哩_bilibili