<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>纯CSS3红心跳动动画特效</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #ffebee;
font-family: 'Arial', sans-serif;
overflow: hidden;
}
.heart-container {
position: relative;
width: 100%;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
/* 心跳动画 */
.heart {
position: relative;
width: 100px;
height: 90px;
animation: heartbeat 1.5s ease-in-out infinite;
transform-origin: center;
}
.heart:before, .heart:after {
content: "";
position: absolute;
top: 0;
width: 50px;
height: 80px;
background: #ff4757;
border-radius: 50px 50px 0 0;
}
.heart:before {
left: 50px;
transform: rotate(-45deg);
transform-origin: 0 100%;
box-shadow: -5px -5px 20px rgba(255, 71, 87, 0.5);
}
.heart:after {
left: 0;
transform: rotate(45deg);
transform-origin: 100% 100%;
box-shadow: 5px -5px 20px rgba(255, 71, 87, 0.5);
}
/* 心跳动画效果 */
@keyframes heartbeat {
0% {
transform: scale(0.9);
}
5% {
transform: scale(1);
}
10% {
transform: scale(0.9);
}
15% {
transform: scale(1.1);
}
50% {
transform: scale(0.9);
}
100% {
transform: scale(0.9);
}
}
/* 心跳波纹效果 */
.ripple {
position: absolute;
width: 100px;
height: 100px;
background: rgba(255, 71, 87, 0.2);
border-radius: 50%;
animation: ripple 2s ease-out infinite;
opacity: 0;
}
.ripple:nth-child(2) {
animation-delay: 0.5s;
}
.ripple:nth-child(3) {
animation-delay: 1s;
}
@keyframes ripple {
0% {
transform: scale(0.5);
opacity: 0.5;
}
100% {
transform: scale(2.5);
opacity: 0;
}
}
/* 文字效果 */
.text {
position: absolute;
bottom: 20%;
color: #ff4757;
font-size: 24px;
font-weight: bold;
text-align: center;
text-shadow: 0 0 10px rgba(255, 71, 87, 0.3);
animation: textPulse 2s ease-in-out infinite;
}
@keyframes textPulse {
0%, 100% {
transform: scale(1);
opacity: 0.8;
}
50% {
transform: scale(1.05);
opacity: 1;
}
}
/* 引用链接 */
.credit {
position: absolute;
bottom: 20px;
color: #ff4757;
font-size: 14px;
opacity: 0.7;
}
.credit a {
color: #ff4757;
text-decoration: none;
}
</style>
</head>
<body>
<div class="heart-container">
<div class="heart"></div>
<div class="ripple"></div>
<div class="ripple"></div>
<div class="ripple"></div>
<div class="text">心跳的感觉</div>
</div>
</body>
</html>
纯CSS3红心跳动动画特效
于 2025-06-23 14:27:12 首次发布