实现CSS3星系旋转效果代

快乐打工仔 分类:实例代码

CSS3星系旋转效果代属于前端实例代码,有关更多实例代码大家可以查看

分享一段代码实例,它模拟实现了星系行星围绕着恒星旋转的效果。

代码实例如下:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.pipipi.net/" />
<title>犀牛前端部落</title>
<style>
* {
padding: 0;
margin: 0;
}
body {
width: 100%;
height: 100%;
background-color: #080e24;
}
ul {
height: 600px;
width: 600px;
margin: 50px auto;
list-style: none;
}
ul li {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
border: 2px solid #333333;
}
li:nth-child(1) {
width: 60px;
height: 60px;
border-radius: 50%;
box-shadow: 0 0 50px #B3C04C;
background-color: #B3C04C;
}
li:nth-child(2) {
width: 120px;
height: 120px;
border-radius: 50%;
animation: rotate 30s linear infinite;
}
li:nth-child(2) span {
width: 15px;
height: 15px;
border-radius: 50%;
background-color: red;
position: absolute;
top: 0;
left: 25px;
}
li:nth-child(3) {
width: 180px;
height: 180px;
border-radius: 50%;
animation: rotate 20s linear infinite;
}
li:nth-child(3) span {
width: 20px;
height: 20px;
border-radius: 50%;
background-color: green;
position: absolute;
top: 0;
left: 35px;
}
li:nth-child(4) {
width: 240px;
height: 240px;
border-radius: 50%;
animation: rotate 20s linear infinite;
}
li:nth-child(4) span {
width: 18px;
height: 18px;
border-radius: 50%;
background-color: deepskyblue;
position: absolute;
top: 0;
left: 60px;
}
li:nth-child(5) {
width: 300px;
height: 300px;
border-radius: 50%;
animation: rotate 10s linear infinite;
}
li:nth-child(5) > span {
width: 25px;
height: 25px;
border-radius: 50%;
background-color: #6dff39;
position: absolute;
top: 0;
left: 135px;
animation: rotate 10s linear infinite;
}
li:nth-child(5) > span span {
width: 10px;
height: 10px;
border-radius: 50%;
background-color: #ff40c0;
position: absolute;
top: 0;
left: 30px;
}
li:nth-child(6) {
width: 360px;
height: 360px;
border-radius: 50%;
animation: rotate 30s linear infinite;
}
li:nth-child(6) span {
width: 10px;
height: 10px;
border-radius: 50%;
background-color: #faff27;
position: absolute;
top: 0;
left: 130px;
}
li:nth-child(7) {
width: 420px;
height: 420px;
border-radius: 50%;
animation: rotate 40s linear infinite;
}
li:nth-child(7) > span {
width: 25px;
height: 25px;
border-radius: 50%;
background-color: #801377;
position: absolute;
top: 0;
left: 190px;
animation: rotate 15s linear infinite;
}
li:nth-child(7) > span span {
width: 10px;
height: 10px;
border-radius: 50%;
background-color: #4afff8;
position: absolute;
top: 0;
left: 30px;
}
li:nth-child(8) {
width: 480px;
height: 480px;
border-radius: 50%;
animation: rotate 10s linear infinite;
}
li:nth-child(8) span {
width: 15px;
height: 15px;
border-radius: 50%;
background-color: #3f8042;
position: absolute;
top: 0;
left: 175px;
}
li:nth-child(9) {
width: 540px;
height: 540px;
border-radius: 50%;
}
@keyframes rotate {
0% {
transform: translate(-50%,-50%) rotate(0deg);
}
100% {
transform: translate(-50%,-50%) rotate(360deg);
}
}
</style>
</head>
<body>
<ul>
<li></li>
<li><span></span></li>
<li><span></span></li>
<li><span></span></li>
<li><span><span></span></span></li>
<li><span></span></li>
<li><span><span></span></span></li>
<li><span></span></li>
<li></li>
</ul>
</body>
</html>

CSS3星系旋转效果代,这样的场景在实际项目中还是用的比较多的,关于CSS3星系旋转效果代就介绍到这了。

回复

我来回复
  • 暂无回复内容