CSS3动画——飞行的小精灵

server/2024/10/18 5:59:12/

CSS3动画——飞行的小精灵

今天的这段代码通过多层结构、渐变色、圆角、多种动画效果以及细节处理,成功地创造了一个充满活力和趣味性的飞行小精灵动画效果。
效果如下:

飞行的小精灵

源代码如下:

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>飞行的小精灵</title><style>css">* {padding: 0;margin: 0;}body {background-color: rgb(15, 17, 29);width: 100%;overflow: hidden;}div {width: 150px;height: 150px;}ul {display: block;width: 100%;height: 100%;font-size: 0px;}/* 最外层容器 */.container {translate: 0 50%;margin: 0 auto;width: 100%;height: 300px;}.main-container {position: relative;width: 100%;height: 100%;}/* 外层紫色盒子 */.first {margin: 0 auto;translate: 0 50%;/* border: 1px solid #fff; */box-shadow: 5px 5px 10px 5px rgba(80, 72, 160, 0.9) 30%, rgb(126, 117, 224, 0.5);}/* 紫色拖尾 */.first ul li {width: 100%;height: 25%;border-top-right-radius: 15px;border-bottom-right-radius: 15px;animation: first .7s ease-in-out infinite alternate;background-image: linear-gradient(to right, rgba(80, 72, 160, 0.9) 30%, rgb(126, 117, 224, 0.5));mask-image: linear-gradient(to right, rgba(80, 72, 160, 0.9) 70%, transparent);}.first ul li:nth-child(1) {animation-delay: .3s;}.first ul li:nth-child(2) {animation: first 2s 0.4s ease-out infinite alternate;}.first ul li:nth-child(3) {animation: first 1.5s 0.3s ease-out infinite alternate;}.first ul li:nth-child(4) {animation-delay: .5s;}@keyframes first {0% {width: 60%;opacity: 1;}100% {width: 140%;}}.first::before {content: '';position: absolute;left: -50%;width: 50%;height: 100%;border-top-left-radius: 75px;border-bottom-left-radius: 75px;background-color: rgba(80, 72, 160, 0.9);box-shadow: -2px 0 5px rgba(80, 72, 160, 0.7);}/* 第二层 */.second {margin: 0 auto;translate: 0 -50%;height: 130px;}.second ul li {height: 25%;width: 100%;background-color: rgba(133, 237, 232, 0.6);border-top-right-radius: 15px;border-bottom-right-radius: 15px;animation: second .6s ease-out infinite alternate;mask-image: linear-gradient(to right, #85EDE8 50%, transparent);}.second ul li:last-child {translate: 0 200%;animation-delay: 0.4s;}@keyframes second {0% {width: 80%;}100% {width: 130%;}}.second::before {content: '';position: absolute;left: -65px;width: 50%;height: 100%;border-top-left-radius: 75px;border-bottom-left-radius: 75px;background: #85EDE8;box-shadow: -2px 0 5px rgba(133, 237, 232, 0.7);}/* 第三层 */.third {position: relative;margin: 0 auto;translate: 0 -205px;}.third ul li {width: 100%;height: 10%;border-top-right-radius: 7.5px;border-bottom-right-radius: 7.5px;background-color: rgb(133, 237, 232);animation: third 1s infinite alternate;box-shadow: 0 0 5px rgba(133, 237, 232, 0.5);}.third .top {position: absolute;top: 10px;left: 0;}.third .bottom {position: absolute;bottom: 10px;left: 0;}.third ul li:nth-child(1) {animation-delay: 0.7s;}.third ul li:nth-child(2) {width: 25px;height: 15px;border-radius: 50px;animation: third-1 1.5s ease-out infinite;}.third ul li:nth-child(4) {width: 15px;border-radius: 50px;animation: third-1 1.5s ease-out infinite;}.third ul li:nth-child(3) {width: 50px;border-radius: 50px;animation: third-2 1s 0.1s ease-out infinite;}.third ul li:nth-child(5) {width: 60px;border-radius: 70px;animation: third-2 1s 0.4s ease-out infinite;}@keyframes third {0% {width: 55%;}100% {width: 85%;}}@keyframes third-1 {0% {left: 35px;}80% {cpacity: 0.7;}100% {left: 200px;opacity: 0;}}@keyframes third-2 {0% {left: 35px;}80% {cpacity: 0.7;}100% {left: 200px;opacity: 0;}}.third::before {content: '';position: absolute;top: 25px;left: -50px;width: 70px;height: 100px;border-top-left-radius: 65px;border-bottom-left-radius: 65px;background-color: #fff;}/* 面部的图案,待会儿取消注释*/.fourth {position: relative;width: 100px;height: 100px;background-color: transparent;margin: 0 auto;/* 因为前面的div盒子撑起来了 */translate: -25px -330%;background-color: #fff;}.fourth .eyes {position: absolute;top: 40px;left: 0px;width: 10px;height: 10px;border-radius: 50%;background-color: #000;}.eyes::after {content: "";position: absolute;top: 0;left: 30px;width: 10px;height: 10px;border-radius: 50%;background-color: #000;}.checks {position: absolute;top: 52px;left: -10px;width: 10px;height: 10px;border-radius: 50%;background-color: rgb(133, 237, 232);}.checks::after {content: "";position: absolute;top: 0;left: 50px;width: 10px;height: 10px;border-radius: 50%;background-color: rgb(133, 237, 232);}.smile {position: absolute;top: 53px;left: 8px;width: 20px;height: 10px;border: 3px solid #000;border-bottom-left-radius: 90px;border-bottom-right-radius: 90px;}/* 嘴型的设置 */.smile::after {content: "";position: absolute;top: -5px;left: -5px;width: 30px;height: 7px;background-color: #fff;}/* 设置动画条 */.fourth ul li {position: absolute;width: 100%;height: 15px;background-color: #fff;left: 1px;}.fourth ul .odd {border-top-right-radius: 50px;border-bottom-right-radius: 50px;}.fourth ul .even {background: radial-gradient(circle at 100% 50%, transparent 15px, #fff 18px);}.fourth ul li:nth-child(1) {top: 0px;animation: fourth-1 1s ease-in-out infinite alternate;}.fourth ul li:nth-child(2) {top: 12px;height: 17px;animation: fourth-2 1s 0.2s ease-in-out infinite alternate;filter: blur(1px);}.fourth ul li:nth-child(3) {top: 27px;animation: fourth-3 1s 0.4s ease-in-out infinite alternate;}.fourth ul li:nth-child(4) {top: 41px;height: 17px;animation: fourth-4 1s 0.6s ease-in-out infinite alternate;}.fourth ul li:nth-child(5) {bottom: 28px;animation: fourth-5 1s 0.6s ease-in-out infinite alternate;}.fourth ul li:nth-child(6) {bottom: 14px;animation: fourth-6 01s 0.6s ease-in-out infinite alternate;}.fourth ul li:nth-child(7) {bottom: 0px;animation: fourth-7 1s 0.6s ease-in-out infinite alternate;}@keyframes fourth-1 {0% {width: 120%;}100% {width: 140%;}}@keyframes fourth-2 {0% {width: 120%}100% {width: 125%;}}@keyframes fourth-3 {0% {width: 130%;}100% {width: 150%;}}@keyframes fourth-4 {0% {width: 125%;}100% {width: 140%;}}@keyframes fourth-5 {0% {width: 120%;}100% {width: 150%;}}@keyframes fourth-6 {0% {width: 120%;}100% {width: 130%;}}@keyframes fourth-7 {0% {width: 130%;}100% {width: 155%;}}@keyframes fourth-8 {0% {width: 155%;}100% {width: 165%;}}</style>
</head><body><div class="container"><div class="main-container"><!-- 外层紫色 --><div class="first"><ul><li></li><li></li><li></li><li></li></ul></div><!-- 第二层浅蓝 --><div class="second"><ul><li></li><li></li></ul></div><!-- 第三层稍微深的蓝色 --><div class="third"><ul><li class="top"></li><li class="top"></li><li class="top"></li><li class="bottom"></li><li class="bottom"></li><li class="bottom"></li></ul></div><!-- 内层图案 --><div class="fourth"><ul><li class="odd"></li><li class="even"></li><li class="odd"></li><li class="even"></li><li class="odd"></li><li class="even"></li><li class="odd"></li><li class="even"></li></ul><!-- 面部图像 --><span class="eyes"></span><span class="checks"></span><span class="smile"></span></div></div><div class=" flying-starts"></div></div>
</body></html>

http://www.ppmy.cn/server/109700.html

相关文章

中国各省环境污染指数(原始数据及结果)(2008-2022年)

环境污染综合指数利用熵值法计算得出的综合性评估指标&#xff0c;旨在全面反映中国各省区环境污染的整体状况。该指数的数据主要来源于《中国统计NJ》及各省的统计NJ&#xff0c;通过收集并分析多项环境污染相关指标&#xff08;废水排放总量、废气中二氧化硫排放量、一般工业…

win7一键修复所有dll缺失!全面介绍电脑DLL文件丢失修复过程!

在Windows 7操作系统中&#xff0c;DLL&#xff08;动态链接库&#xff09;文件扮演着至关重要的角色。它们是Windows系统和其他应用程序正常运行所必需的组件。然而&#xff0c;由于各种原因&#xff0c;如系统更新不当、软件卸载不完全或恶意软件攻击&#xff0c;DLL文件可能…

Linux单用户模式和救援模式

Linux单用户模式和救援模式 init守护进程Linux系统启动级别init查看Linux启动级别init修改启动级别&#xff1a; systemd守护进程Linux系统启动级别systemd查看启动级别systemd修改启动级别 rescue单用户模式Initramfs模式进入Initramfs救援模式 修改被救援Linux的配置挂载boot…

使用VScode的Git版本控制功能(图文版)

☁️ 前言 今天让我来手把手教你简单入门VScode自带的Git版本控制。 &#x1f389; 初始化仓库 初始化仓库之后&#xff0c;仓库里的文件发生了任何改动都会有相应的提示&#xff0c;这对于我们开发和维护项目非常有帮助。 &#x1f389;提交更改 初始化仓库之后&#xff…

跟《经济学人》学英文:2024年08月31日这期 How Abercrombie Fitch got hot again

How Abercrombie & Fitch got hot again The once-troubled brand is now a favourite of millennials and gen-Zs alike Abercrombie & Fitch&#xff08;简称A&F&#xff09;是一家美国著名的时尚品牌&#xff0c;成立于1892年。最初&#xff0c;A&F以其高端…

C# 常量

1. 什么是常量 常量(constant)是表示常量值(即,可以在编译时计算的值)的类成员 常量隶属于类型而不是对象,即没有“实例常量” “实例常量”的角色由只读实例字段来担当 注意区分成员常量与局部常量 成员常量通常是指在类或结构中声明的常量字段。它们在整个类的作用域内都是…

快递盒检测检测系统源码分享 # [一条龙教学YOLOV8标注好的数据集一键训练_70+全套改进创新点发刊_Web前端展示]

快递盒检测检测系统源码分享 [一条龙教学YOLOV8标注好的数据集一键训练_70全套改进创新点发刊_Web前端展示] 1.研究背景与意义 项目参考AAAI Association for the Advancement of Artificial Intelligence 项目来源AACV Association for the Advancement of Computer Visio…

分布式:浅谈幂等

幂等&#xff08;idempotent、idempotence&#xff09;是一个数学与计算机学概念&#xff0c;常见于抽象代数中。 在编程中&#xff0c;一个幂等操作的特点是其任意多次执行所产生的影响均与一次执行的影响相同。幂等函数&#xff0c;或幂等方法&#xff0c;是指可以使用相同参…