<!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: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
overflow: hidden;
}
.scene {
position: relative;
width: 300px;
height: 300px;
display: flex;
justify-content: center;
align-items: center;
}
/* 伊布容器 */
.eevee {
position: relative;
width: 200px;
height: 150px;
animation: bounce 2s ease-in-out infinite;
}
/* 头部 */
.head {
position: absolute;
width: 100px;
height: 90px;
background: #A5775B;
border-radius: 50% 50% 45% 45% / 60% 60% 40% 40%;
top: 0;
left: 50px;
z-index: 10;
box-shadow: inset -5px -10px 0 rgba(0, 0, 0, 0.1);
}
/* 耳朵 */
.ear {
position: absolute;
width: 30px;
height: 50px;
background: #A5775B;
top: -30px;
border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}
.ear.left {
left: 20px;
transform: rotate(-20deg);
}
.ear.right {
right: 20px;
transform: rotate(20deg);
}
.ear::before {
content: '';
position: absolute;
width: 15px;
height: 30px;
background: #D4A37F;
border-radius: 50% 50% 0 0 / 100% 100% 0 0;
bottom: 0;
left: 7.5px;
}
/* 面部 */
.face {
position: absolute;
width: 80px;
height: 70px;
background: #D4A37F;
border-radius: 50%;
top: 15px;
left: 10px;
}
/* 眼睛 */
.eye {
position: absolute;
width: 15px;
height: 20px;
background: #000;
border-radius: 50%;
top: 25px;
}
.eye.left {
left: 25px;
}
.eye.right {
right: 25px;
}
.eye::before {
content: '';
position: absolute;
width: 5px;
height: 5px;
background: #fff;
border-radius: 50%;
top: 5px;
left: 3px;
}
/* 鼻子 */
.nose {
position: absolute;
width: 8px;
height: 6px;
background: #000;
border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
top: 45px;
left: 46px;
}
/* 嘴巴 */
.mouth {
position: absolute;
width: 20px;
height: 10px;
border-bottom: 2px solid #000;
border-radius: 0 0 50% 50%;
top: 55px;
left: 40px;
}
/* 胡须 */
.whisker {
position: absolute;
width: 2px;
height: 15px;
background: #000;
top: 50px;
}
.whisker.left-1 {
left: 30px;
transform: rotate(20deg);
}
.whisker.left-2 {
left: 30px;
transform: rotate(10deg);
top: 52px;
}
.whisker.right-1 {
right: 30px;
transform: rotate(-20deg);
}
.whisker.right-2 {
right: 30px;
transform: rotate(-10deg);
top: 52px;
}
/* 身体 */
.body {
position: absolute;
width: 120px;
height: 80px;
background: #A5775B;
border-radius: 50% 50% 40% 40% / 60% 60% 40% 40%;
top: 70px;
left: 40px;
z-index: 5;
}
/* 前腿 */
.leg {
position: absolute;
width: 20px;
height: 40px;
background: #A5775B;
bottom: -20px;
border-radius: 10px;
z-index: 4;
}
.leg.front.left {
left: 50px;
animation: leg-move 2s ease-in-out infinite;
}
.leg.front.right {
left: 90px;
animation: leg-move 2s ease-in-out infinite reverse;
}
/* 后腿 */
.leg.back.left {
left: 30px;
height: 50px;
bottom: -30px;
transform: rotate(10deg);
animation: back-leg-move 2s ease-in-out infinite;
}
.leg.back.right {
left: 110px;
height: 50px;
bottom: -30px;
transform: rotate(-10deg);
animation: back-leg-move 2s ease-in-out infinite reverse;
}
/* 尾巴 */
.tail {
position: absolute;
width: 30px;
height: 80px;
background: #A5775B;
border-radius: 15px;
top: 80px;
left: 130px;
transform-origin: left center;
transform: rotate(-30deg);
z-index: 1;
animation: tail-wag 2s ease-in-out infinite;
}
.tail::before {
content: '';
position: absolute;
width: 40px;
height: 60px;
background: #D4A37F;
border-radius: 20px;
top: 10px;
left: 10px;
}
/* 颈部毛发 */
.fur {
position: absolute;
width: 80px;
height: 40px;
background: #D4A37F;
border-radius: 20px;
top: 60px;
left: 60px;
z-index: 6;
}
/* 动画 */
@keyframes bounce {
0%, 100% {
transform: translateY(0);
}
50% {
transform: translateY(-20px);
}
}
@keyframes leg-move {
0%, 100% {
transform: translateY(0) rotate(0deg);
}
50% {
transform: translateY(-10px) rotate(10deg);
}
}
@keyframes back-leg-move {
0%, 100% {
transform: translateY(0) rotate(10deg);
}
50% {
transform: translateY(-10px) rotate(0deg);
}
}
@keyframes tail-wag {
0%, 100% {
transform: rotate(-30deg);
}
50% {
transform: rotate(-10deg);
}
}
/* 地面 */
.ground {
position: absolute;
width: 300px;
height: 50px;
background: linear-gradient(to top, #8B7D6B, #BCA88E);
border-radius: 50% 50% 0 0 / 100% 100% 0 0;
bottom: 0;
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}
/* 心形 */
.heart {
position: absolute;
width: 20px;
height: 20px;
background: #ff6b6b;
transform: rotate(-45deg);
top: 20px;
right: 30px;
opacity: 0;
animation: heart-beat 2s ease-in-out infinite;
}
.heart::before, .heart::after {
content: '';
position: absolute;
width: 20px;
height: 20px;
background: #ff6b6b;
border-radius: 50%;
}
.heart::before {
top: -10px;
left: 0;
}
.heart::after {
top: 0;
left: 10px;
}
@keyframes heart-beat {
0%, 100% {
transform: rotate(-45deg) scale(0);
opacity: 0;
}
50% {
transform: rotate(-45deg) scale(1);
opacity: 1;
}
}
/* 星星特效 */
.star {
position: absolute;
width: 10px;
height: 10px;
background: #fff;
clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
opacity: 0;
animation: twinkle 2s ease-in-out infinite;
}
.star:nth-child(1) {
top: 30px;
left: 40px;
animation-delay: 0.2s;
}
.star:nth-child(2) {
top: 50px;
right: 50px;
animation-delay: 0.4s;
}
.star:nth-child(3) {
bottom: 60px;
left: 60px;
animation-delay: 0.6s;
}
@keyframes twinkle {
0%, 100% {
opacity: 0;
transform: scale(0.5);
}
50% {
opacity: 1;
transform: scale(1);
}
}
/* 标题样式 */
.title {
position: absolute;
top: 20px;
font-family: 'Arial', sans-serif;
color: #A5775B;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
font-size: 24px;
font-weight: bold;
}
/* 链接样式 */
.link {
position: absolute;
bottom: 20px;
font-family: 'Arial', sans-serif;
color: #A5775B;
text-decoration: none;
font-size: 12px;
}
.link:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="scene">
<h1 class="title">伊布 CSS3 动画</h1>
<div class="eevee">
<!-- 耳朵 -->
<div class="ear left"></div>
<div class="ear right"></div>
<!-- 头部 -->
<div class="head">
<div class="face"></div>
<div class="eye left"></div>
<div class="eye right"></div>
<div class="nose"></div>
<div class="mouth"></div>
<div class="whisker left-1"></div>
<div class="whisker left-2"></div>
<div class="whisker right-1"></div>
<div class="whisker right-2"></div>
</div>
<!-- 颈部毛发 -->
<div class="fur"></div>
<!-- 身体 -->
<div class="body"></div>
<!-- 腿 -->
<div class="leg front left"></div>
<div class="leg front right"></div>
<div class="leg back left"></div>
<div class="leg back right"></div>
<!-- 尾巴 -->
<div class="tail"></div>
<!-- 心形 -->
<div class="heart"></div>
<!-- 星星 -->
<div class="star"></div>
<div class="star"></div>
<div class="star"></div>
</div>
<!-- 地面 -->
<div class="ground"></div>
</div>
</body>
</html>
纯CSS3绘制神奇宝贝伊布动画特效
于 2025-06-24 13:52:52 首次发布

被折叠的 条评论
为什么被折叠?



