|
|

楼主 |
发表于 2022-4-7 23:09
|
显示全部楼层
全部代码:- <style>
- #outer {
- margin: auto;
- width: 760px;
- height: 700px;
- background: #333;
- position: relative;
- }
- #outer div { position: absolute; border-radius: 50%; }
- #sun {
- --x: 50px;
- width: 80px;
- height: 80px;
- left: calc(50% - 40px);
- top: calc(50% - 40px);
- background: gold;
- box-shadow: 0 0 10px white;
- animation: orbit 40s linear infinite
- }
- #earth {
- --x: 200px;
- width: 40px;
- height: 40px;
- left: calc(50% - 20px);
- top: calc(50% - 20px);
- background: aqua;
- animation: orbit 36.5s linear infinite;
- }
- #moon {
- --x: 60px;
- width: 20px;
- height: 20px;
- left: calc(50% - 10px);
- top: calc(50% - 10px);
- background: white;
- animation: orbit 2.7s linear infinite;
- }
- @keyframes orbit {
- from { transform: rotate(0deg) translateY(var(--x)) rotate(0deg); }
- to { transform: rotate(360deg) translateY(var(--x)) rotate(-360deg); }
- }
- </style>
- <div id="outer">
- <div id="sun">
- <div id="earth">
- <div id="moon"></div>
- </div>
- </div>
- </div>
复制代码
|
|