28 星际旋转

效果演示

28-星际旋转.gif

实现了一个太阳系动画,其中包括了地球、火星、金星、土星、水星、天王星、海王星以及火卫二号等行星的动画效果。太阳系的行星都被放在一个固定的容器中,并使用CSS动画来实现旋转和移动的效果。当太阳系的行星绕着太阳运行时,它们会围绕太阳旋转,并且在运行过程中会发生碰撞和交叉。

Code

<div class="wrapper"><div class="neptune-container"><img src="img/neptune.png" /></div><div class="uranus-container"><img src="img/uranus.svg" /></div><div class="saturn-container"><img src="img/saturn.png" /></div><div class="jupiter-container"><img src="img/jupiter.png" /></div><div class="mars-container"><img src="img/mars.png" /></div><div class="earth-container"><img src="img/earth.png" /></div><div class="venus-container"><img src="img/venus.png" /></div><div class="mercury-container"><img src="img/mercury.png" /></div><div class="sun-container"><img src="img/sun.png" /></div>
</div>
* {margin: 0;padding: 0;box-sizing: border-box;
}body {display: flex;justify-content: center;align-items: center;height: 100vh;background-image: url(img/space-background.jpg)
}.wrapper {height: 100%;width: 100%;display: flex;justify-content: center;align-items: center;
}.wrapper div {position: absolute;border-radius: 100%;display: flex;justify-content: center;align-items: center;border: 1px solid white;position: absolute;
}.neptune-container {height: 850px;width: 850px;
}.neptune-container>img {height: 50px;width: 50px;animation: neptune-rotation 53954ms linear infinite;
}.uranus-container {height: 750px;width: 750px;
}.uranus-container>img {height: 75px;width: 75px;animation: uranus-rotation 37054ms linear infinite;
}.saturn-container {height: 600px;width: 600px;
}.saturn-container>img {height: 75px;width: 75px;animation: saturn-rotation 33218ms linear infinite;
}.jupiter-container {height: 500px;width: 500px;
}.jupiter-container>img {height: 75px;width: 75px;animation: jupiter-rotation 27339ms linear infinite;
}.mars-container {height: 400px;width: 400px;
}.mars-container>img {height: 35px;width: 35px;animation: mars-rotation 12684ms linear infinite;
}.earth-container {height: 350px;width: 350px;
}.earth-container>img {height: 30px;width: 30px;animation: earth-rotation 11079ms linear infinite;
}.venus-container {height: 300px;width: 300px;
}.venus-container>img {height: 20px;width: 20px;animation: venus-rotation 7259ms linear infinite;
}.mercury-container {height: 250px;width: 250px;
}.mercury-container>img {height: 15px;width: 15px;animation: mercury-rotation 5768ms linear infinite;
}.sun-container {height: 200px;width: 200px;border-radius: 100%;display: flex;justify-content: center;align-items: center;
}.sun-container>img {height: 310px;width: 310px;
}@keyframes neptune-rotation {0% {transform: rotate(0deg) translate(425px) rotate(0deg);}100% {transform: rotate(360deg) translate(425px) rotate(360deg);}
}@keyframes uranus-rotation {0% {transform: rotate(0deg) translate(375px) rotate(0deg);}100% {transform: rotate(360deg) translate(375px) rotate(360deg);}
}@keyframes saturn-rotation {0% {transform: rotate(0deg) translate(300px) rotate(0deg);}100% {transform: rotate(360deg) translate(300px) rotate(360deg);}
}@keyframes jupiter-rotation {0% {transform: rotate(0deg) translate(250px) rotate(0deg);}100% {transform: rotate(360deg) translate(250px) rotate(360deg);}
}@keyframes mars-rotation {0% {transform: rotate(0deg) translate(200px) rotate(0deg);}100% {transform: rotate(360deg) translate(200px) rotate(360deg);}
}@keyframes earth-rotation {0% {transform: rotate(0deg) translate(175px) rotate(0deg);}100% {transform: rotate(360deg) translate(175px) rotate(360deg);}
}@keyframes venus-rotation {0% {transform: rotate(0deg) translate(150px) rotate(0deg);}100% {transform: rotate(360deg) translate(150px) rotate(360deg);}
}@keyframes mercury-rotation {0% {transform: rotate(0deg) translate(125px) rotate(0deg);}100% {transform: rotate(360deg) translate(125px) rotate(360deg);}
}

实现思路拆分

* {margin: 0;padding: 0;box-sizing: border-box;
}

这段代码是设置全局样式,包括设置元素的盒模型为border-box,即盒模型的宽度和高度包括内容、内边距、边框和外边距。

body {display: flex;justify-content: center;align-items: center;height: 100vh;background-image: url(img/space-background.jpg)
}

这段代码是设置整个页面的样式,包括设置页面的高度为100vh,即视口的高度,使页面填充整个屏幕。同时,设置页面的背景图片为space-background.jpg。

.wrapper {height: 100%;width: 100%;display: flex;justify-content: center;align-items: center;
}

这段代码是设置一个容器的样式,包括设置容器的高度和宽度为100%,使容器填充整个屏幕。同时,设置容器的显示方式为flex,使容器中的元素可以自动排列。

.wrapper div {position: absolute;border-radius: 100%;display: flex;justify-content: center;align-items: center;border: 1px solid white;position: absolute;
}

这段代码是设置太阳系中的行星的样式,包括设置行星的位置为绝对定位,使其相对于容器的位置进行定位。同时,设置行星的圆角半径为100%,使其变成一个圆形。设置行星的显示方式为flex,使其中的元素可以自动排列。设置行星的边框为1px solid white,使其看起来像一个白色的圆形。

.neptune-container {height: 850px;width: 850px;
}.neptune-container>img {height: 50px;width: 50px;animation: neptune-rotation 53954ms linear infinite;
}

这段代码是设置尼普斯星的样式,包括设置行星的高度和宽度为850px,使其变成一个圆形。同时,设置行星的动画效果为neptune-rotation,即使用CSS动画实现行星的旋转效果。

.uranus-container {height: 750px;width: 750px;
}.uranus-container>img {height: 75px;width: 75px;animation: uranus-rotation 37054ms linear infinite;
}

这段代码是设置乌拉斯星的样式,包括设置行星的高度和宽度为750px,使其变成一个圆形。同时,设置行星的动画效果为uranus-rotation,即使用CSS动画实现行星的旋转效果。

.saturn-container {height: 600px;width: 600px;
}.saturn-container>img {height: 75px;width: 75px;animation: saturn-rotation 33218ms linear infinite;
}

这段代码是设置土星的样式,包括设置行星的高度和宽度为600px,使其变成一个圆形。同时,设置行星的动画效果为saturn-rotation,即使用CSS动画实现行星的旋转效果。

.jupiter-container {height: 500px;width: 500px;
}.jupiter-container>img {height: 75px;width: 75px;animation: jupiter-rotation 27339ms linear infinite;
}

这段代码是设置木星的样式,包括设置行星的高度和宽度为500px,使其变成一个圆形。同时,设置行星的动画效果为jupiter-rotation,即使用CSS动画实现行星的旋转效果。

.mars-container {height: 400px;width: 400px;
}

这段代码是设置火星的样式,包括设置行星的高度和宽度为400px,使其变成一个圆形。

.mars-container>img {height: 35px;width: 35px;animation: mars-rotation 12684ms linear infinite;
}

这段代码是设置火星的图片样式,包括设置图片的高度和宽度为35px,使其变成一个圆形。同时,设置图片的动画效果为mars-rotation,即使用CSS动画实现行星的旋转效果。

.earth-container {height: 350px;width: 350px;
}

这段代码是设置地球的样式,包括设置行星的高度和宽度为350px,使其变成一个圆形。

.earth-container>img {height: 30px;width: 30px;animation: earth-rotation 11079ms linear infinite;
}

这段代码是设置地球的图片样式,包括设置图片的高度和宽度为30px,使其变成一个圆形。同时,设置图片的动画效果为earth-rotation,即使用CSS动画实现行星的旋转效果。

.venus-container {height: 300px;width: 300px;
}

这段代码是设置金星的样式,包括设置行星的高度和宽度为300px,使其变成一个圆形。

.venus-container>img {height: 20px;width: 20px;animation: venus-rotation 7259ms linear infinite;
}

这段代码是设置金星的图片样式,包括设置图片的高度和宽度为20px,使其变成一个圆形。同时,设置图片的动画效果为venus-rotation,即使用CSS动画实现行星的旋转效果。

.mercury-container {height: 250px;width: 250px;
}

这段代码是设置水星的样式,包括设置行星的高度和宽度为250px,使其变成一个圆形。

.mercury-container>img {height: 15px;width: 15px;animation: mercury-rotation 5768ms linear infinite;
}

这段代码是设置水星的图片样式,包括设置图片的高度和宽度为15px,使其变成一个圆形。同时,设置图片的动画效果为mercury-rotation,即使用CSS动画实现行星的旋转效果。

.sun-container {height: 200px;width: 200px;border-radius: 100%;display: flex;justify-content: center;align-items: center;
}

这段代码是设置太阳的样式,包括设置行星的高度和宽度为200px,使其变成一个圆形。同时,设置行星的圆角半径为100%,使其变成一个圆形。设置行星的显示方式为flex,使其中的元素可以自动排列。设置行星的居中方式为居中对齐,使其在容器中居中显示。

.sun-container>img {height: 310px;width: 310px;
}

这段代码是设置太阳的图片样式,包括设置图片的高度和宽度为310px,使其变成一个圆形。

@keyframes neptune-rotation {0% {transform: rotate(0deg) translate(425px) rotate(0deg);}100% {transform: rotate(360deg) translate(425px) rotate(360deg);}
}

这段代码是定义了一个名为neptune-rotation的CSS动画,用于实现尼普斯星的旋转动画。该动画包含两个关键帧,分别为0%和100%。在0%时,尼普斯星的旋转角度为0度,并向右移动425px。在100%时,尼普斯星的旋转角度为360度,并向右移动425px。

@keyframes uranus-rotation {0% {transform: rotate(0deg) translate(375px) rotate(0deg);}100% {transform: rotate(360deg) translate(375px) rotate(360deg);}
}

这段代码是定义了一个名为uranus-rotation的CSS动画,用于实现乌拉斯星的旋转动画。该动画包含两个关键帧,分别为0%和100%。在0%时,乌拉斯星的旋转角度为0度,并向右移动375px。在100%时,乌拉斯星的旋转角度为360度,并向右移动375px。

@keyframes saturn-rotation {0% {transform: rotate(0deg) translate(300px) rotate(0deg);}100% {transform: rotate(360deg) translate(300px) rotate(360deg);}
}

这段代码是定义了一个名为saturn-rotation的CSS动画,用于实现土星的旋转动画。该动画包含两个关键帧,分别为0%和100%。在0%时,土星的旋转角度为0度,并向右移动300px。在100%时,土星的旋转角度为360度,并向右移动300px。

@keyframes jupiter-rotation {0% {transform: rotate(0deg) translate(250px) rotate(0deg);}100% {transform: rotate(360deg) translate(250px) rotate(360deg);}
}

这段代码是定义了一个名为jupiter-rotation的CSS动画,用于实现木星的旋转动画。该动画包含两个关键帧,分别为0%和100%。在0%时,木星的旋转角度为0度,并向右移动250px。在100%时,木星的旋转角度为360度,并向右移动250px。

@keyframes mars-rotation {0% {transform: rotate(0deg) translate(200px) rotate(0deg);}100% {transform: rotate(360deg) translate(200px) rotate(360deg);}
}

这段代码是定义了一个名为mars-rotation的CSS动画,用于实现火星的旋转动画。该动画包含两个关键帧,分别为0%和100%。在0%时,火星的旋转角度为0度,并向右移动200px。在100%时,火星的旋转角度为360度,并向右移动200px。

@keyframes earth-rotation {0% {transform: rotate(0deg) translate(175px) rotate(0deg);}100% {transform: rotate(360deg) translate(175px) rotate(360deg);}
}

这段代码是设置地球的动画效果,包括设置动画的名称为earth-rotation,即使用CSS动画实现地球的旋转效果。在0%时,将地球的位置设置为0deg,并将其向右移动175px。在100%时,将地球的位置设置为360deg,并将其向右移动175px。

@keyframes venus-rotation {0% {transform: rotate(0deg) translate(150px) rotate(0deg);}100% {transform: rotate(360deg) translate(150px) rotate(360deg);}
}

这段代码是设置金星的动画效果,包括设置动画的名称为venus-rotation,即使用CSS动画实现金星的旋转效果。在0%时,将金星的位置设置为0deg,并将其向右移动150px。在100%时,将金星的位置设置为360deg,并将其向右移动150px。

@keyframes mercury-rotation {0% {transform: rotate(0deg) translate(125px) rotate(0deg);}100% {transform: rotate(360deg) translate(125px) rotate(360deg);}
}

这段代码是设置水星的动画效果,包括设置动画的名称为mercury-rotation,即使用CSS动画实现水星的旋转效果。在0%时,将水星的位置设置为0deg,并将其向右移动125px。在100%时,将水星的位置设置为360deg,并将其向右移动125px。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/620605.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

PHP运算符汇总

⭕️前些天发现了一个巨牛的人工智能学习网站&#xff0c;通俗易懂&#xff0c;风趣幽默&#xff0c;忍不住分享一下给大家(点击跳转到网站)⭕️ 一、算数运算符 基础理解 加减乘除、求余数、整数除法&#xff08;向下取整&#xff09;、字符串拼接等 <?php $x10; $y…

电子学会C/C++编程等级考试2021年09月(四级)真题解析

C/C++编程(1~8级)全部真题・点这里 第1题:最佳路径 如下所示的由正整数数字构成的三角形: 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5 从三角形的顶部到底部有很多条不同的路径。对于每条路径,把路径上面的数加起来可以得到一个和,和最大的路径称为最佳路径。你的任务就是求出最佳路径…

Rust-trait

Rust语言中的trait是非常重要的概念。 在Rust中&#xff0c;trait这一个概念承担了多种职责。在中文里&#xff0c;trait可以翻译为“特征”“特点”“特性”等。 成员方法 trait中可以定义函数。用例子来说明&#xff0c;我们定义如下的trait: 上面这个trait包含了一个方法…

【C++入门到精通】智能指针 [ C++入门 ]

阅读导航 引言一、什么是智能指针二、为什么需要智能指针三、内存泄漏1. 什么是内存泄漏&#xff0c;内存泄漏的危害2. 内存泄漏的示例&#xff0c;以及解决方法3. 内存泄漏分类&#xff08;1&#xff09;堆内存泄漏(Heap leak)&#xff08;2&#xff09;系统资源泄漏 4. 如何检…

FFmpeg 的使用与Docker安装流媒体服务器

本文阐述的均为命令行的使用方式&#xff0c;并不牵扯FFmpeg 的 C音视频开发内容&#xff0c;补充一句&#xff0c;C的资料真的少&#xff0c;能把C学好的人&#xff0c;我真的是觉得巨佬。 我主要是使用FFmpeg 推流方面的知识&#xff0c;案例大都是靠近这方面。 一、FFmpeg…

常用Java代码-Java中的并发集合(ConcurrentHashMap、CopyOnWriteArrayList等)

在Java中&#xff0c;并发集合是一组为多线程环境设计的集合类&#xff0c;它们提供了线程安全的操作。这些集合类包括ConcurrentHashMap&#xff0c;CopyOnWriteArrayList等。以下是对这两个类的一个简单的代码解释。 1.ConcurrentHashMap ConcurrentHashMap是Java并发包jav…

如何在“Microsoft Visual Studio”中使用OpenCV构建应用程序

我在这里描述的所有内容都将应用于 OpenCV 的界面。我首先假设您已经阅读并成功完成了 Windows 中的安装教程。因此&#xff0c;在进一步操作之前&#xff0c;请确保您有一个包含 OpenCV 头文件和二进制文件的 OpenCV 目录&#xff0c;并且您已按照此处所述设置环境变量 设置 O…

迅腾文化用网络集成化生态系统助力品牌之路的坚实后盾

商业竞争激烈&#xff0c;品牌不仅是企业的标志和形象&#xff0c;更是其核心价值和竞争力的体现。然而&#xff0c;企业在品牌推广过程中面临着诸多如缺乏有效的渠道管理、品牌形象模糊以及竞争激烈的市场环境等。这些阻碍着企业的品牌发展和市场占有率的提升。本文将通过企业…

C语言辨析——深入理解格式字符的用法

1. 问题 下面程序为什么的输出结果为什么不是25而是0&#xff1f;问题出在哪&#xff1f; #include <stdio.h> #include <math.h> int main() {int a3,b4; printf("%d\n",pow(a,2)pow(b,2)); return 0; } 2. 分析 函数pow的返回类型是double&…

双周赛121(模拟、位运算、BFS、数位DP上下界)

文章目录 双周赛121[2996. 大于等于顺序前缀和的最小缺失整数](https://leetcode.cn/problems/smallest-missing-integer-greater-than-sequential-prefix-sum/)模拟 [2997. 使数组异或和等于 K 的最少操作次数](https://leetcode.cn/problems/minimum-number-of-operations-to…

线上剧本杀小程序搭建,未来线上剧本杀有哪些发展优势?

剧本杀游戏是当下比较流行的一种新型游戏模式&#xff0c;它能够让玩家在游戏中进行角色扮演&#xff0c;体验不同的角色人生&#xff0c;沉浸式玩游戏&#xff0c;因此受到了众多年轻人的喜欢。随着互联网科技的发展&#xff0c;剧本杀的发展也转型到了互联网上&#xff0c;为…

爬虫—抓取表情党热门栏目名称及链接

爬虫—抓取表情党热门栏目名称及链接 表情党网址&#xff1a;https://qq.yh31.com/ 目标&#xff1a;抓取表情党主页的热门栏目名称及对应的链接&#xff0c;如下图所示&#xff1a; 按F12&#xff08;谷歌浏览器&#xff09;&#xff0c;进入开发者工具模式&#xff0c;进行…

【打卡】牛客网:BM84 最长公共前缀

自己写的&#xff1a; 题目要求时间复杂度是o(n*len)&#xff0c;说明可以遍历所有的字符。 空间复杂度o(1)&#xff0c;说明不能用字符串存储公共前缀&#xff0c;所以用下标来记录。 调试过程&#xff1a; 大概花了20min。 我调试前的做法是&#xff0c;在while循环中&…

网络设备远程运维管理解决方案

在当今高度信息化的时代&#xff0c;网络设备远程运维管理已成为企业运营中的一项核心任务。随着设备数量不断增加&#xff0c;分布日益广泛&#xff0c;传统的现场维护方式已无法满足企业对效率和经济性的需求。如何寻找一种高效、便捷的设备远程运维管理系统&#xff0c;已成…

【WPF.NET开发】文档批注

本文内容 便笺要点数据锚定匹配批注与批注对象 在纸质文档上编写说明或注释毫不稀奇&#xff0c;我们几乎认为这是理所当然的。 这些说明或注释就是“批注”&#xff0c;我们将其添加到文档&#xff0c;用于标注信息或突出显示兴趣项以供日后参考。 虽然在打印文档上编写注释…

c++语言基础21-图形的面积(面向对象)

21 图形的面积 题目描述 考虑一个简单的图形类层次结构&#xff0c;包括基类 Shape 和两个派生类 Rectangle 和 Circle。每个类都有一个用于计算面积的方法。你的任务是编写一个程序&#xff0c;根据输入数据创建一个图形对象&#xff0c;然后计算并输出其面积。 输入描述 输…

大数据StarRocks(七):数据表创建

1. 基本概念 1.1 Row & Column 一张表包括行&#xff08;Row&#xff09;和列&#xff08;Column&#xff09;。Row 即用户的一行数据。Column 用于描述一行数据中不同的字段。 ⚫ 在默认的数据模型中&#xff0c;Column 只分为排序列和非排序列。存储引擎会按照排序列对…

RK3568笔记八: Display子系统

modetest 是由 libdrm 提供的测试程序&#xff0c;可以查询显示设备的特性&#xff0c;进行基本的显示测试&#xff0c;以及设置显示的模式。 我们可以借助该工具来学习 Linux DRM 应用编程&#xff0c;另外为了深入分析 Rockchip DRM driver&#xff0c;有必要先了解一下这个…

Hive基础知识(十三):Hive的Group by语句与Having语句

1. Group By 语句 GROUP BY 语句通常会和聚合函数一起使用&#xff0c;按照一个或者多个列队结果进行分组&#xff0c;然后对每个组执行聚合操作。 1&#xff09;案例实操&#xff1a; &#xff08;1&#xff09;计算 emp 表每个部门的平均工资 hive (default)> select de…

PHP AES 加密示例

PHP中实现AES加密的一个基本示例涉及到使用openssl_encrypt函数。这个函数允许你使用不同的加密算法&#xff0c;包括AES。下面是一个简单的示例&#xff0c;展示了如何使用AES加密一个字符串。 首先&#xff0c;你需要确定几个关键的参数&#xff1a; 数据&#xff08;Data&…