|
|

楼主 |
发表于 2022-8-4 13:36
|
显示全部楼层
代码分享:
- <style>
- #papa { left: -214px; width: 1024px; height: 600px; background: #336699 url('https://638183.freep.cn/638183/Pic/81/7036.jpg') no-repeat center/cover; box-shadow: 3px 3px 30px #000; position: relative; overflow: hidden; }
- .mpic { position: absolute; width: 124px; height: 221px; right: -124px; bottom: -130px; }
- #disc { position: absolute; width: 60px; height: 60px; right: 20px; bottom: 20px; background: conic-gradient(red,orange,yellow,green,teal,blue,purple); border-radius: 50%; mask: radial-gradient(transparent 4px,red 0); -webkit-mask: radial-gradient(transparent 4px,red 0); animation: rot 2s linear infinite; cursor: pointer; z-index: 100; }
- @keyframes rot { to { transform: rotate(360deg); } }
- @keyframes shot { from {transform: translate(0px, 0px) rotate(-45deg); } to { transform: translate(-1084px, -600px) rotate(-45deg); }}
- </style>
- <div id="papa"><span id="disc"></span></div>
- <script>
- let arr = [0,1,2,3,4,5], aud = new Audio();
- aud.src = 'https://music.163.com/song/media/outer/url?id=1428166708.mp3';
- aud.loop = true;
- aud.autoplay = true;
- disc.style.animationPlayState = aud.paused ? 'paused' : 'running';
- for(x of arr) {
- let ele = document.createElement('img');
- ele.className = 'mpic';
- ele.src = 'https://638183.freep.cn/638183/Pic/81/tj.gif';
- ele.alt = '';
- ele.style.animation = 'shot 4s linear ' + x * .6 + 's infinite';
- papa.appendChild(ele);
- }
- disc.onclick = () => aud.paused ? aud.play() : aud.pause();
- aud.addEventListener('playing',() => disc.style.animationPlayState = 'running');
- aud.addEventListener('pause',() => disc.style.animationPlayState = 'paused');
- </script>
复制代码
|
|