在上一篇《html+ccs3太阳系行星运转动画》中实现了太阳系八大行星的基本运转动画。

太阳系又何止这些内容,为丰富一下动画,接下来增加“土星环”和“月球”来充盈太阳系动画。

下面是充盈后的动画效果静态图。

一、土星环

修改原来土星的div,在外面放一个包裹层div,class设成saturn-container。

内部放4个div,一个用来显示土星这个圆球,3个用来显示土星环。

        <div class='saturn-container'>
<div class="saturn"></div>
<div class="saturn-ring-1"></div>
<div class="saturn-ring-2"></div>
<div class="saturn-ring-3"></div>
</div>

土星包裹层css,负责本层的定位和转动动画。

        .saturn-container {
left:92px;
top:387px;
height: 26px;
width: 26px;
position: absolute;
transform-origin: 308px 13px;
animation: rotate 183.92s infinite linear;
}

三个土星环div。

        /*土星环-内圈*/
.saturn-ring-1 {
height: 30px;
width: 30px;
border-color: rgb(184,186,164);
border-width: 4px;
border-style: solid;
border-radius: 50%; } /*土星环-中间*/
.saturn-ring-2 {
height: 40px;
width: 40px;
border-color: rgb(169,171,149);
border-width: 2px;
border-style: solid;
border-radius: 50%;
} /*土星环-外圈*/
.saturn-ring-3 {
height: 46px;
width: 46px;
border-color: rgb(187,190,175);
border-width: 1px;
border-style: solid;
border-radius: 50%;
}

放完后的效果。

土星的那个圆球和三个环都在了,但并不是土星环的同心圆的排列方式,还是块级元素的独立行排列。

为了让他们变成同心圆,通过为3个环设上margin的,margin的值用负值,这样就可以让圆环往上移动,调整数值让他们形成同心圆环。

增加了margin后的css。

        /*土星环-内圈*/
.saturn-ring-1 {
height: 30px;
width: 30px;
margin-top:-32px;
margin-left: -6px;
border-color: rgb(184,186,164);
border-width: 4px;
border-style: solid;
border-radius: 50%; } /*土星环-中间*/
.saturn-ring-2 {
height: 40px;
width: 40px;
margin-top:-41px;
margin-left: -9px;
border-color: rgb(169,171,149);
border-width: 2px;
border-style: solid;
border-radius: 50%;
} /*土星环-外圈*/
.saturn-ring-3 {
height: 46px;
width: 46px;
margin-top:-46px;
margin-left: -11px;
border-color: rgb(187,190,175);
border-width: 1px;
border-style: solid;
border-radius: 50%;
}

增加margin后的效果。

二、地球的卫星-月球

修改原来地球的div,在外面放一个包裹层div,class设成earth-container。

内部放3个div,一个用来显示地球,一个用来显示月球轨道,一个用来显示月球,效果如上图。

        <div class='earth-container'>
<div class='earth'></div>
<div class="moonOrbit"></div>
<div class="moon"></div>
</div>

地球包裹层css,负责本层以及其中所有元素的定位和围绕着太阳的转动动画。

        .earth-container {
left:244px;
top:369px;
height: 61px;
width: 61px;
position: absolute;
transform-origin: 156px 31px;
animation: rotate 6.25s infinite linear;
}

地球,一个圆球,定位在包裹层的中间。

        .earth {
left:21px;
top:21px;
height: 19px;
width: 19px;
background-color: rgb(115,114,174);
border-radius: 50%;
position: absolute;
}

月球轨道,一个虚线圆环,定位在包裹层的中间。

        .moonOrbit {
left:10px;
top:10px;
height: 41px;
width: 41px;
background-color: transparent;
border-radius: 50%;
border-style: dashed;
border-color: gray;
position: absolute;
border-width: 1px;
margin: 0px;
padding: 0px;
}

月球,其中心点定位在月球轨道圆环的上,并围绕着地球的中心(包裹层的中心点)做rotate动画。

        .moon {
left:8px;
top:28px;
height: 5px;
width: 5px;
background-color: rgb(140,119,63);
border-radius: 50%;
position: absolute;
transform-origin: 24px 4px;
animation: rotate 2s infinite linear;
}

完成。

全部代码:

<html>
<head>
<style>
.solarsys{
width: 800px;
height: 800px;;
position: relative;
margin: 0 auto;
background-color: #000000;
padding: 0;
transform: scale(1);
} /*太阳*/
.sun {
left:357px;
top:357px;
height: 90px;
width: 90px;
background-color: rgb(248,107,35);
border-radius: 50%;
box-shadow: 5px 5px 10px rgb(248,107,35), -5px -5px 10px rgb(248,107,35), 5px -5px 10px rgb(248,107,35), -5px 5px 10px rgb(248,107,35);
position: absolute;
margin: 0;
} /*水星*/
.mercury {
left:337.5px;
top:395px;
height: 10px;
width: 10px;
background-color: rgb(166,138,56);
border-radius: 50%;
position: absolute;
transform-origin: 62.5px 5px;
animation: rotate 1.5s infinite linear;
} /*水星轨道*/
.mercuryOrbit {
left:342.5px;
top:342.5px;
height: 115px;
width: 115px;
background-color: transparent;
border-radius: 50%;
border-style: dashed;
border-color: gray;
position: absolute;
border-width: 1px;
margin: 0px;
padding: 0px;
} /*金星*/
.venus {
left:309px;
top:389px;
height: 22px;
width: 22px;
background-color: rgb(246,157,97);
border-radius: 50%;
position: absolute;
transform-origin: 91px 11px;
animation: rotate 3.84s infinite linear;
} /*金星轨道*/
.venusOrbit {
left:320px;
top:320px;
height: 160px;
width: 160px;
background-color: transparent;
border-radius: 50%;
border-style: dashed;
border-color: gray;
position: absolute;
border-width: 1px;
margin: 0px;
padding: 0px;
} /*地球效果容器*/
.earth-container {
left:244px;
top:369px;
height: 61px;
width: 61px;
position: absolute;
transform-origin: 156px 31px;
animation: rotate 6.25s infinite linear;
} /*地球*/
.earth {
left:21px;
top:21px;
height: 19px;
width: 19px;
background-color: rgb(115,114,174);
border-radius: 50%;
position: absolute;
} /*月球轨道*/
.moonOrbit {
left:10px;
top:10px;
height: 41px;
width: 41px;
background-color: transparent;
border-radius: 50%;
border-style: dashed;
border-color: gray;
position: absolute;
border-width: 1px;
margin: 0px;
padding: 0px;
} /*月球*/
.moon {
left:8px;
top:28px;
height: 5px;
width: 5px;
background-color: rgb(140,119,63);
border-radius: 50%;
position: absolute;
transform-origin: 24px 4px;
animation: rotate 2s infinite linear;
} /*地球轨道*/
.earthOrbit {
left:275px;
top:275px;
height: 250px;
width: 250px;
background-color: transparent;
border-radius: 50%;
border-style: dashed;
border-color: gray;
position: absolute;
border-width: 1px;
margin: 0px;
padding: 0px;
} /*火星*/
.mars {
left:222.5px;
top:392.5px;
height: 15px;
width: 15px;
background-color: rgb(140,119,63);
border-radius: 50%;
position: absolute;
transform-origin: 177.5px 7.5px;
animation: rotate 11.75s infinite linear;
} /*火星轨道*/
.marsOrbit {
left:230px;
top:230px;
height: 340px;
width: 340px;
background-color: transparent;
border-radius: 50%;
border-style: dashed;
border-color: gray;
position: absolute;
border-width: 1px;
margin: 0px;
padding: 0px;
} /*木星*/
.jupiter {
left:134px;
top:379px;
height: 42px;
width: 42px;
background-color: rgb(156,164,143);
border-radius: 50%;
position: absolute;
transform-origin: 266px 21px;
animation: rotate 74.04s infinite linear;
} /*木星轨道*/
.jupiterOrbit {
left:155px;
top:155px;
height: 490px;
width: 490px;
background-color: transparent;
border-radius: 50%;
border-style: dashed;
border-color: gray;
position: absolute;
border-width: 1px;
margin: 0px;
padding: 0px;
} /*土星效果容器*/
.saturn-container {
left:92px;
top:387px;
height: 26px;
width: 26px;
position: absolute;
transform-origin: 308px 13px;
animation: rotate 183.92s infinite linear;
} /*土星*/
.saturn {
height: 26px;
width: 26px;
background-color: rgb(215,171,68);
border-radius: 50%;
} /*土星环-内圈*/
.saturn-ring-1 {
height: 30px;
width: 30px;
margin-top:-32px;
margin-left: -6px;
border-color: rgb(184,186,164);
border-width: 4px;
border-style: solid;
border-radius: 50%; } /*土星环-中间*/
.saturn-ring-2 {
height: 40px;
width: 40px;
margin-top:-41px;
margin-left: -9px;
border-color: rgb(169,171,149);
border-width: 2px;
border-style: solid;
border-radius: 50%;
} /*土星环-外圈*/
.saturn-ring-3 {
height: 46px;
width: 46px;
margin-top:-46px;
margin-left: -11px;
border-color: rgb(187,190,175);
border-width: 1px;
border-style: solid;
border-radius: 50%;
} /*土星轨道*/
.saturnOrbit {
left:105px;
top:105px;
height: 590px;
width: 590px;
background-color: transparent;
border-radius: 50%;
border-style: dashed;
border-color: gray;
position: absolute;
border-width: 1px;
margin: 0px;
padding: 0px;
} /*天王星*/
.uranus {
left:41.5px;
top:386.5px;
height: 27px;
width: 27px;
background-color: rgb(164,192,206);
border-radius: 50%;
position: absolute;
transform-origin: 358.5px 13.5px;
animation: rotate 524.46s infinite linear;
} /*天王星轨道*/
.uranusOrbit {
left:55px;
top:55px;
height: 690px;
width: 690px;
background-color: transparent;
border-radius: 50%;
border-style: dashed;
border-color: gray;
position: absolute;
border-width: 1px;
margin: 0px;
padding: 0px;
} /*海王星*/
.neptune {
left:10px;
top:390px;
height: 20px;
width: 20px;
background-color: rgb(133,136,180);
border-radius: 50%;
position: absolute;
transform-origin: 390px 10px;
animation: rotate 1028.76s infinite linear;
} /*海王星轨道*/
.neptuneOrbit {
left:20px;
top:20px;
height: 760px;
width: 760px;
background-color: transparent;
border-radius: 50%;
border-style: dashed;
border-color: gray;
position: absolute;
border-width: 1px;
margin: 0px;
padding: 0px;
} @keyframes rotate {
100% {
transform: rotate(-360deg);
}
} </style> </head>
<body>
<div class="solarsys">
<!--太阳-->
<div class='sun'></div> <!--水星轨道-->
<div class='mercuryOrbit'></div> <!--水星-->
<div class='mercury'></div> <!--金星轨道-->
<div class='venusOrbit'></div> <!--金星-->
<div class='venus'></div> <!--地球轨道-->
<div class='earthOrbit'></div> <!--地球-->
<!--<div class='earth'></div>-->
<div class='earth-container'>
<div class='earth'></div>
<div class="moonOrbit"></div>
<div class="moon"></div>
</div> <!--火星轨道-->
<div class='marsOrbit'></div> <!--火星-->
<div class='mars'></div> <!--木星轨道-->
<div class='jupiterOrbit'></div> <!--木星-->
<div class='jupiter'></div> <!--土星轨道-->
<div class='saturnOrbit'></div> <!--土星-->
<!--<div class='saturn'></div>-->
<div class='saturn-container'>
<div class="saturn"></div>
<div class="saturn-ring-1"></div>
<div class="saturn-ring-2"></div>
<div class="saturn-ring-3"></div>
</div> <!--天王星轨道-->
<div class='uranusOrbit'></div> <!--天王星-->
<div class='uranus'></div> <!--海王星轨道-->
<div class='neptuneOrbit'></div> <!--海王星-->
<div class='neptune'></div>
</div>
</body>
</html>

html+ccs3太阳系行星运转动画之土星有个环,地球有颗小卫星的更多相关文章

  1. html+ccs3太阳系行星运转动画

    做一个太阳系八大行星的运转动画,不包括行星的卫星,所有行星围绕太阳公转,行星采用纯色,暂时没有自转. 效果静态图: 动画中包括:太阳及各行星,运行轨道,行星公转动画. 先画好草图,设计好大小和位置,根 ...

  2. 【Web动画】CSS3 3D 行星运转 && 浏览器渲染原理

    承接上一篇:[CSS3进阶]酷炫的3D旋转透视 . 最近入坑 Web 动画,所以把自己的学习过程记录一下分享给大家. CSS3 3D 行星运转 demo 页面请戳:Demo.(建议使用Chrome打开 ...

  3. 使用css3的动画模拟太阳系行星公转

    本文介绍使用css3的animation画一个太阳系行星公转的动画,再加以改进,讨论如何画椭圆的运行轨迹.然后分析京东和人人网使用animation的实际案例,最后结合css3的clip-path做一 ...

  4. css3加js做一个简单的3D行星运转效果

    前几天在园子里看到一篇关于CSS3D行星运转的文章,原文在这里,感觉这个效果也太酷炫了,于是自己也就心血来潮的来尝试的做了一下.因为懒得去用什么插件了,于是就原生的JS写,效果有点粗超,还有一些地方处 ...

  5. three.js模拟实现太阳系行星体系

    概况如下: 1.SphereGeometry实现自转的太阳: 2.RingGeometry实现太阳系星系的公转轨道: 3.ImageUtils加载球体和各行星贴图: 4.canvas中createRa ...

  6. OpenGL 太阳系行星拾取例子(GL_SELECT) VS2008 + glut实现

    太阳系:Solar System 以太阳(Sun)为中心,由内到外分别是: 水星(Mercury) 金星(Venus) 地球(Earth) 火星(Mars) 木星(Jupiter) 土星(Saturn ...

  7. 3D_solarSys

    计算机图形学_3DsolarSys 一.软件功能        1.实现3D太阳系,有太阳.土星.土星环.地球.月球.天王星.海王星.火星.其中土星.地球.天王星.海王星.火星绕着太阳转,土星环绕着土 ...

  8. CSS动画实例:行星和卫星

    设页面中有<div class=" planet "></div>,用来绘制一个行星和卫星图形.这个图形包括三部分:行星.卫星和卫星旋转的轨道.定义. pl ...

  9. 认识我们的太阳系(Solar System)

    一.初识太阳系 如果太阳是一颗篮球,那么我们的地球是什么?? 如果太阳系里最大的行星:木星是一颗足球,那么我们的地球是什么?? 如果我们的地球是一颗排球,那么其他行星是什么?? 由此,我们可以看到,我 ...

随机推荐

  1. scrapy 知乎用户信息爬虫

    zhihu_spider 此项目的功能是爬取知乎用户信息以及人际拓扑关系,爬虫框架使用scrapy,数据存储使用mongo,下载这些数据感觉也没什么用,就当为大家学习scrapy提供一个例子吧.代码地 ...

  2. nodejs中获取时间戳、时间差

    Nodejs中获取时间戳的方法有很多种,例如: new Date().getTime() Date.now() process.uptime() process.hrtime() 平时想获取一个时间戳 ...

  3. Hawk 4.6 并行化

    并行化 Hawk支持单机并行化,也就是使用多线程获取数据.它可以控制目前所有任务的数量,为了不给网站造成过大的压力,仅当任务池中的任务数量小于一定值后,才会插入新的任务. 你可以在数据清洗的 执行面板 ...

  4. Javascript实现HashTable类

    散列算法可以尽快在数据结构中找出指定的一个值,因为可以通过Hash算法求出值的所在位置,存储和插入的时候都按照Hash算法放到指定位置. <script> function HashTab ...

  5. 拼图小游戏之计算后样式与CSS动画的冲突

    先说结论: 前几天写了几个非常简单的移动端小游戏,其中一个拼图游戏让我郁闷了一段时间.因为要获取每张图片的位置,用`<style>`标签写的样式,直接获取计算后样式再用来交换位置,结果就悲 ...

  6. [原]HAproxy 代理技术原理探究

    HAproxy 技术分享 简介 HAProxy是一款提供高可用性.负载均衡以及基于TCP(第四层)和HTTP(第七层)应用的代理软件 Features 1.免费 2.能够做到4层以上代理 3.高性能 ...

  7. linux centos中添加删除修改环境变量,设置java环境变量

    前言 安装完软件必要添加环境变量.指令很少,然而长时间不写就会不自信:我写的对吗?于是百度开始,于是发现又是各有千秋.好吧,好记星不如烂笔头.当然,最重要的是,百度出来的都他妈的是如何添加环境变量,只 ...

  8. css常用hack

    原文地址:css常用hack 突然想起今天早上在CNZZ看到的统计数据,使用IE6.7的用户比例还真多,看到之后我的心都碎了.微软都放弃了为毛还有这么多人不死心? 所以说,IE下的兼容还是得做的. – ...

  9. 【干货分享】流程DEMO-外出申请

    流程名: 外出申请  流程相关文件: 流程包.xml  流程说明: 直接导入流程包文件,即可使用本流程  表单:   流程: 图片:2.png DEMO包下载: http://files.cnblog ...

  10. 前端开发小白必学技能—非关系数据库又像关系数据库的MongoDB快速入门命令(2)

    今天给大家道个歉,没有及时更新MongoDB快速入门的下篇,最近有点小忙,在此向博友们致歉.下面我将简单地说一下mongdb的一些基本命令以及我们日常开发过程中的一些问题.mongodb可以为我们提供 ...