|
|

楼主 |
发表于 2025-7-19 17:41
|
显示全部楼层
代码
- <style>
- #player {
- margin: 100px 0 100px calc(50% - 150px);
- position: relative;
- width: 300px;
- height: 300px;
- border-radius: 50%;
- background: radial-gradient(beige, skyblue);
- perspective: 600px;
- transform-style: preserve-3d;
- }
- .ring {
- position: absolute;
- width: 100%;
- height: 100%;
- border: thick dashed var(--cc);
- border-radius: 50%;
- transform: translateZ(-30px) rotateX(var(--ax)) rotateY(var(--ay));
- }
- </style>
- <div id="player" title="播放/暂停"></div>
- <script>
- var total = 15, rings = [], step = 0.5, isRun = false, raf;
- Array.from({length: total}).forEach( (d,k) => {
- d = document.createElement('div');
- d.className = 'ring';
- const a = k * 360 / total;
- d.style.cssText += `
- --ax: ${a}deg;
- --ay: ${a}deg;
- --cc: #${Math.random().toString(16).substring(2,8)};
- `;
- rings.push({ elm: d, a: a });
- player.appendChild(d);
- });
- const animate = () => {
- rings.forEach( (d, k) => {
- d.a = d.a + step;
- d.elm.style.setProperty('--ax', d.a + 'deg');
- d.elm.style.setProperty('--ay', d.a + 'deg');
- });
- raf = requestAnimationFrame(animate);
- };
- player.onclick = () => {
- isRun = !isRun;
- isRun ? animate() : cancelAnimationFrame(raf);
- };
- </script>
复制代码
|
评分
-
| 参与人数 1 | 威望 +50 |
金钱 +100 |
经验 +50 |
收起
理由
|
红影
| + 50 |
+ 100 |
+ 50 |
赞一个! |
查看全部评分
|