CSS3白云飘动动画特效

<!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 {

height: 100vh; /* 视口高度 */

background: linear-gradient(to bottom, #87CEEB 0%, #E0F7FA 100%); /* 天空渐变背景 */

overflow: hidden; /* 隐藏溢出内容 */

position: relative; /* 相对定位 */

font-family: Arial, sans-serif; /* 字体设置 */

}

/* 白云基础样式 */

.cloud {

position: absolute; /* 绝对定位 */

background: white; /* 白色云朵 */

border-radius: 50%; /* 圆形 */

filter: blur(5px); /* 模糊效果使云更柔和 */

opacity: 0.9; /* 半透明效果 */

animation-timing-function: linear; /* 线性动画 */

animation-iteration-count: infinite; /* 无限循环 */

}

/* 大白云样式 */

.cloud-large {

width: 150px; /* 宽度 */

height: 60px; /* 高度 */

animation-name: moveCloudLarge; /* 动画名称 */

animation-duration: 60s; /* 动画时长 */

}

/* 中白云样式 */

.cloud-medium {

width: 100px; /* 宽度 */

height: 40px; /* 高度 */

animation-name: moveCloudMedium; /* 动画名称 */

animation-duration: 40s; /* 动画时长 */

}

/* 小白云样式 */

.cloud-small {

width: 70px; /* 宽度 */

height: 30px; /* 高度 */

animation-name: moveCloudSmall; /* 动画名称 */

animation-duration: 30s; /* 动画时长 */

}

/* 大白云动画 */

@keyframes moveCloudLarge {

0% {

left: -200px; /* 起始位置 */

top: 20%; /* 垂直位置 */

transform: scale(1); /* 初始大小 */

}

50% {

transform: scale(1.1); /* 中间变大 */

}

100% {

left: 110%; /* 移动到右侧 */

top: 15%; /* 轻微上下浮动 */

transform: scale(1); /* 恢复大小 */

}

}

/* 中白云动画 */

@keyframes moveCloudMedium {

0% {

left: -150px; /* 起始位置 */

top: 40%; /* 垂直位置 */

transform: scale(1); /* 初始大小 */

}

50% {

transform: scale(1.05); /* 中间轻微变大 */

}

100% {

left: 110%; /* 移动到右侧 */

top: 35%; /* 轻微上下浮动 */

transform: scale(1); /* 恢复大小 */

}

}

/* 小白云动画 */

@keyframes moveCloudSmall {

0% {

left: -100px; /* 起始位置 */

top: 60%; /* 垂直位置 */

transform: scale(1); /* 初始大小 */

}

50% {

transform: scale(1.03); /* 中间轻微变大 */

}

100% {

left: 110%; /* 移动到右侧 */

top: 65%; /* 轻微上下浮动 */

transform: scale(1); /* 恢复大小 */

}

}

/* 云朵阴影部分(增强立体感) */

.cloud::before, .cloud::after {

content: ''; /* 伪元素内容 */

position: absolute; /* 绝对定位 */

background: white; /* 白色 */

border-radius: 50%; /* 圆形 */

filter: blur(3px); /* 模糊效果 */

}

/* 大云朵的阴影部分 */

.cloud-large::before {

width: 80px; /* 宽度 */

height: 80px; /* 高度 */

top: -30px; /* 位置 */

left: 20px; /* 位置 */

}

.cloud-large::after {

width: 50px; /* 宽度 */

height: 50px; /* 高度 */

top: -20px; /* 位置 */

left: 80px; /* 位置 */

}

/* 中云朵的阴影部分 */

.cloud-medium::before {

width: 60px; /* 宽度 */

height: 60px; /* 高度 */

top: -20px; /* 位置 */

left: 10px; /* 位置 */

}

.cloud-medium::after {

width: 40px; /* 宽度 */

height: 40px; /* 高度 */

top: -15px; /* 位置 */

left: 50px; /* 位置 */

}

/* 小云朵的阴影部分 */

.cloud-small::before {

width: 40px; /* 宽度 */

height: 40px; /* 高度 */

top: -15px; /* 位置 */

left: 10px; /* 位置 */

}

.cloud-small::after {

width: 30px; /* 宽度 */

height: 30px; /* 高度 */

top: -10px; /* 位置 */

left: 35px; /* 位置 */

}

/* 网站链接样式 */

.website-link {

position: fixed; /* 固定定位 */

bottom: 20px; /* 底部位置 */

right: 20px; /* 右侧位置 */

color: #333; /* 文字颜色 */

font-size: 14px; /* 字体大小 */

text-decoration: none; /* 无下划线 */

z-index: 100; /* 层级 */

}

/* 标题样式 */

.title {

position: absolute; /* 绝对定位 */

top: 50%; /* 垂直居中 */

left: 50%; /* 水平居中 */

transform: translate(-50%, -50%); /* 精确居中 */

color: white; /* 白色文字 */

font-size: 36px; /* 字体大小 */

text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3); /* 文字阴影 */

z-index: 10; /* 层级 */

}

</style>

</head>

<body>

<!-- 标题 -->

<h1 class="title">白云飘动动画特效</h1>

<!-- 大白云 -->

<div class="cloud cloud-large" style="animation-delay: 0s;"></div>

<div class="cloud cloud-large" style="animation-delay: 10s;"></div>

<div class="cloud cloud-large" style="animation-delay: 20s;"></div>

<!-- 中白云 -->

<div class="cloud cloud-medium" style="animation-delay: 5s;"></div>

<div class="cloud cloud-medium" style="animation-delay: 15s;"></div>

<div class="cloud cloud-medium" style="animation-delay: 25s;"></div>

<!-- 小白云 -->

<div class="cloud cloud-small" style="animation-delay: 0s;"></div>

<div class="cloud cloud-small" style="animation-delay: 7s;"></div>

<div class="cloud cloud-small" style="animation-delay: 14s;"></div>

<div class="cloud cloud-small" style="animation-delay: 21s;"></div>

</body>

</html>

相关推荐
NiceCloud喜云1 分钟前
Opus 4.8 的 Effort Control 怎么选:Low 到 Max 五档策略
android·java·大数据·前端·c++·python·spring
wordbaby31 分钟前
React Native + RNOH:跨页面数据回传的最佳实践与避坑指南
前端·react native
丷丩33 分钟前
MapLibre GL JS第22课:查看本地GeoJSON
前端·javascript·map·mapbox·maplibre gl js
Front思2 小时前
AI前端工程师需要具备能力+
前端·人工智能·ai
ZC跨境爬虫4 小时前
跟着 MDN 学CSS day_29:(掌握文本与字体样式的核心艺术)
前端·css·ui·html·tensorflow
李子琪。4 小时前
网络空间安全深度实战:CSRF 漏洞原理剖析与基于 Token 的纵深防御体系构建(全栈实验报告)
前端·安全·csrf
冰暮流星4 小时前
javascript之history对象介绍
前端·笔记
IT_陈寒5 小时前
Vite热更新失灵?你可能漏了这个配置
前端·人工智能·后端
丷丩5 小时前
MapLibre GL JS第19课:实时更新要素
前端·javascript·gis·map·mapbox·maplibre gl js
Mr.Daozhi5 小时前
RAG 进阶实战:跑通 Demo 后我连续翻了 6 次车,逐一修复才真正可用(含 Gradio Web 版)
前端·数据库·langchain·大模型·gradio·rag·科研工具