html5行星环绕,CSS3 星球环绕动画

body {

margin:0;

padding:0;

background:#080e24 url(./bg.jpg) repeat;

}

ul {

width:600px;

height:600px;

margin:40px auto;

position:relative;

list-style:none;

}

ul li {

border:2px solid #394057;

position:absolute;

left:50%;

top:50%;

border-radius:50%;

transform:translate(-50%,-50%);

box-sizing:border-box;

animation-iteration-count:infinite;

animation-timing-function:linear;

animation-name:orbit;

}

ul li span {

display:block;

position:absolute;

left:0;

width:12px;

height:12px;

border-radius:50%;

}

ul li:nth-child(1) {

width:60px;

height:60px;

border:none;

box-shadow:0 0 50px #c90;

background-color:#C90;

animation-duration:5s;

}

ul li:nth-child(2) {

width:120px;

height:120px;

animation-duration:6s;

}

ul li:nth-child(2) span {

background-color:yellow;

left:80px;

top:0;

}

ul li:nth-child(3) {

width:180px;

height:180px;

animation-duration:10s;

}

ul li:nth-child(3) span {

background-color:blue;

left:47px;

top:0;

}

ul li:nth-child(4) {

width:240px;

height:240px;

animation-duration:12s;

}

ul li:nth-child(4) > span {

background-color:green;

left:209px;

top:43px;

animation:orbit 2s infinite linear;

}

ul li:nth-child(4) > span span {

width:6px;

height:6px;

left:16px;

background-color:yellow;

}

ul li:nth-child(5) {

width:300px;

height:300px;

background-image:url(./asteroids_meteorids.png);

background-size:cover;

animation-duration:25s;

}

ul li:nth-child(5) span {

background-color:red;

left:95px;

top:0;

}

ul li:nth-child(6) {

width:360px;

height:360px;

animation-duration:20s;

}

ul li:nth-child(6) span {

background-color:#CCC;

left:-5px;

top:200px;

}

ul li:nth-child(7) {

width:420px;

height:420px;

animation-duration:30s;

}

ul li:nth-child(7) > span {

background-color:green;

left:300px;

top:18px;

}

ul li:nth-child(7) > span span {

width:15px;

height:15px;

border:2px solid #CCC;

left:-4px;

top:-4px;

transform:skew(0,45deg);

}

ul li:nth-child(8) {

width:480px;

height:480px;

animation-duration:35s;

}

ul li:nth-child(8) span {

background-color:pink;

left:0;

top:170px;

}

ul li:nth-child(9) {

width:540px;

height:540px;

animation-duration:40s;

}

ul li:nth-child(9) span {

background-color:blue;

left:47px;

top:100px;

}

ul li:nth-child(10) {

width:600px;

height:600px;

animation-duration:45s;

}

ul li:nth-child(10) span {

background-color:yellow;

left:224px;

top:0;

}

@keyframes orbit {

0% {

transform:translate(-50%,-50%) rotate(0deg);

}

100% {

transform:translate(-50%,-50%) rotate(360deg);

}

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,我可以为您提供一些基本的代码示例来实现九大行星动画效果。以下是HTML和CSS代码示例: HTML代码: ```html <div class="container"> <div class="sun"></div> <div class="mercury"></div> <div class="venus"></div> <div class="earth"></div> <div class="mars"></div> <div class="jupiter"></div> <div class="saturn"></div> <div class="uranus"></div> <div class="neptune"></div> </div> ``` CSS代码: ```css .container { position: relative; width: 600px; height: 600px; margin: 0 auto; } .sun { position: absolute; top: 50%; left: 50%; margin-top: -50px; margin-left: -50px; width: 100px; height: 100px; border-radius: 50%; background-color: #FFCE00; animation: spin 10s linear infinite; } @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } .mercury { position: absolute; top: 0; left: 50%; margin-left: -5px; width: 10px; height: 10px; border-radius: 50%; background-color: #C2B280; animation: orbit 2s linear infinite; } .venus { position: absolute; top: 0; left: 50%; margin-left: -15px; width: 30px; height: 30px; border-radius: 50%; background-color: #E6D6AD; animation: orbit 4s linear infinite; } .earth { position: absolute; top: 0; left: 50%; margin-left: -25px; width: 50px; height: 50px; border-radius: 50%; background-color: #3F4F5F; animation: orbit 6s linear infinite; } .mars { position: absolute; top: 0; left: 50%; margin-left: -35px; width: 70px; height: 70px; border-radius: 50%; background-color: #E45F56; animation: orbit 8s linear infinite; } .jupiter { position: absolute; top: 0; left: 50%; margin-left: -50px; width: 100px; height: 100px; border-radius: 50%; background-color: #E1B80D; animation: orbit 10s linear infinite; } .saturn { position: absolute; top: 0; left: 50%; margin-left: -65px; width: 130px; height: 130px; border-radius: 50%; background-color: #E1B80D; animation: orbit 12s linear infinite; } .uranus { position: absolute; top: 0; left: 50%; margin-left: -85px; width: 170px; height: 170px; border-radius: 50%; background-color: #9BC4E2; animation: orbit 14s linear infinite; } .neptune { position: absolute; top: 0; left: 50%; margin-left: -100px; width: 200px; height: 200px; border-radius: 50%; background-color: #6384B3; animation: orbit 16s linear infinite; } @keyframes orbit { from { transform: rotate(0deg) translate(150px) rotate(0deg); } to { transform: rotate(360deg) translate(150px) rotate(-360deg); } } ``` 以上代码将会在一个 600px x 600px 的容器内展示太阳系中的九大行星,每个行星都有自己的轨道和大小。太阳会以线性方式旋转,而行星则会沿着其轨道以相同的线性速度运动。请注意,上面的CSS代码中的动画效果仅适用于最新版本的现代浏览器,而在旧版浏览器中可能会有兼容性问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值