<!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>
body {
margin: 0;
padding: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: linear-gradient(to bottom, #87CEEB 0%, #E0F7FA 100%);
overflow: hidden;
font-family: Arial, sans-serif;
}
.scene {
position: relative;
width: 800px;
height: 500px;
}
/* 山 */
.mountain {
position: absolute;
bottom: 0;
width: 0;
height: 0;
border-left: 200px solid transparent;
border-right: 200px solid transparent;
border-bottom: 300px solid #4a6b3a;
left: 50px;
z-index: 1;
}
.mountain:nth-child(2) {
left: 250px;
border-bottom-color: #3a5a2a;
transform: scale(0.8);
}
.mountain:nth-child(3) {
left: 450px;
border-bottom-color: #5a7b4a;
transform: scale(1.2);
}
/* 草地 */
.ground {
position: absolute;
bottom: 0;
width: 100%;
height: 100px;
background: linear-gradient(to bottom, #5a8f3a 0%, #3a6f2a 100%);
z-index: 2;
}
/* 风车 */
.windmill {
position: absolute;
bottom: 100px;
left: 50%;
transform: translateX(-50%);
z-index: 3;
}
.tower {
width: 30px;
height: 150px;
background: linear-gradient(to right, #8B4513 0%, #A0522D 50%, #8B4513 100%);
margin: 0 auto;
position: relative;
}
.roof {
width: 60px;
height: 30px;
background: #A0522D;
margin: 0 auto;
position: relative;
top: -5px;
border-radius: 5px 5px 0 0;
}
.blades {
position: absolute;
top: -80px;
left: 50%;
transform: translateX(-50%);
width: 80px;
height: 80px;
animation: spin 5s linear infinite;
}
.blade {
position: absolute;
width: 20px;
height: 80px;
background: linear-gradient(to bottom, #F5F5DC 0%, #D2B48C 100%);
border-radius: 10px;
transform-origin: bottom center;
}
.blade:nth-child(1) {
transform: rotate(0deg);
}
.blade:nth-child(2) {
transform: rotate(90deg);
}
.blade:nth-child(3) {
transform: rotate(180deg);
}
.blade:nth-child(4) {
transform: rotate(270deg);
}
/* 云 */
.cloud {
position: absolute;
background: white;
border-radius: 50%;
opacity: 0.8;
animation: moveCloud 30s linear infinite;
}
.cloud:nth-child(1) {
width: 100px;
height: 60px;
top: 50px;
left: -100px;
animation-delay: 0s;
}
.cloud:nth-child(2) {
width: 150px;
height: 90px;
top: 80px;
left: -150px;
animation-delay: 5s;
}
.cloud:nth-child(3) {
width: 80px;
height: 50px;
top: 120px;
left: -80px;
animation-delay: 10s;
}
/* 太阳 */
.sun {
position: absolute;
width: 80px;
height: 80px;
background: radial-gradient(circle, #FFD700 0%, #FFA500 70%);
border-radius: 50%;
top: 50px;
right: 100px;
box-shadow: 0 0 40px #FFA500;
}
/* 房子 */
.house {
position: absolute;
bottom: 100px;
left: 100px;
z-index: 2;
}
.house-body {
width: 120px;
height: 100px;
background: linear-gradient(to bottom, #CD853F 0%, #8B4513 100%);
position: relative;
}
.house-roof {
width: 0;
height: 0;
border-left: 70px solid transparent;
border-right: 70px solid transparent;
border-bottom: 50px solid #A0522D;
position: relative;
top: -5px;
}
.house-door {
width: 30px;
height: 50px;
background: #5D4037;
position: absolute;
bottom: 0;
left: 45px;
}
.house-window {
width: 25px;
height: 25px;
background: #ADD8E6;
border: 2px solid #5D4037;
position: absolute;
top: 30px;
left: 20px;
}
.house-window:nth-child(4) {
left: 75px;
}
/* 树 */
.tree {
position: absolute;
bottom: 100px;
right: 100px;
z-index: 2;
}
.tree-trunk {
width: 20px;
height: 60px;
background: linear-gradient(to right, #8B4513 0%, #A0522D 50%, #8B4513 100%);
margin: 0 auto;
}
.tree-top {
width: 0;
height: 0;
border-left: 40px solid transparent;
border-right: 40px solid transparent;
border-bottom: 80px solid #2E8B57;
position: relative;
top: -5px;
}
/* 动画 */
@keyframes spin {
from {
transform: translateX(-50%) rotate(0deg);
}
to {
transform: translateX(-50%) rotate(360deg);
}
}
@keyframes moveCloud {
from {
transform: translateX(-200px);
}
to {
transform: translateX(1000px);
}
}
/* 版权信息 */
.copyright {
position: absolute;
bottom: 10px;
right: 10px;
color: #333;
font-size: 12px;
z-index: 10;
}
.copyright a {
color: #333;
text-decoration: none;
}
.copyright a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="scene">
<!-- 太阳 -->
<div class="sun"></div>
<!-- 云 -->
<div class="cloud"></div>
<div class="cloud"></div>
<div class="cloud"></div>
<!-- 山 -->
<div class="mountain"></div>
<div class="mountain"></div>
<div class="mountain"></div>
<!-- 房子 -->
<div class="house">
<div class="house-roof"></div>
<div class="house-body">
<div class="house-door"></div>
<div class="house-window"></div>
<div class="house-window"></div>
</div>
</div>
<!-- 树 -->
<div class="tree">
<div class="tree-top"></div>
<div class="tree-trunk"></div>
</div>
<!-- 风车 -->
<div class="windmill">
<div class="blades">
<div class="blade"></div>
<div class="blade"></div>
<div class="blade"></div>
<div class="blade"></div>
</div>
<div class="roof"></div>
<div class="tower"></div>
</div>
<!-- 草地 -->
<div class="ground"></div>
</div>
</div>
</body>
</html>
纯CSS3实现山村风车动画特效
1504

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



