|
|

楼主 |
发表于 2024-1-25 18:03
|
显示全部楼层
代码分享
- <style>
- #papa { margin: 0 0 0 calc(50% - 546px); width: 930px; height: 619px; border-radius: 6px; background: #ccc url('https://638183.freep.cn/638183/t24/webp/fjif.webp') no-repeat center/cover; box-shadow: 3px 3px 20px #000; position: relative; z-index: 1; }
- .wrap { position: absolute; bottom: 0; left: calc(50% - 200px); width: 360px; height: 360px; display: grid; place-items: center; }
- .wrap::before { position: absolute; content: ''; width: 75%; height: 75%; border-radius: 50%; box-shadow: inset 0 0 60px rgba(50,10,200,.4); transition: .8s; }
- .wrap:hover::before { box-shadow: inset 0 0 60px rgba(240,10,50,.6); }
- #vid { position: absolute; width: 100%; height: 100%; object-fit: cover; aspect-ratio: 1; pointer-events: none; mix-blend-mode: screen; }
- #player { position: absolute; width: 260px; height: 260px; cursor: pointer; animation: rotating 6s infinite linear var(--state); }
- li-zi { position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #eee; opacity: 0; animation: moving var(--duration) var(--delay) linear infinite alternate var(--state); }
- @keyframes moving { from { transform: translate(var(--x0),var(--y0)); opacity: 0; } to { transform: translate(var(--x1),var(--y1)); opacity: .75; } }
- @keyframes rotating { to { transform: rotate(360deg); } }
- </style>
- <div id="papa">
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=1363152402" autoplay loop></audio>
- <div class="wrap">
- <video id="vid" src="https://img.tukuppt.com/video_show/53950850/03/68/48/645b66b3d9dac.mp4" autoplay loop muted></video>
- <div id="player" title="播放/暂停"></div>
- </div>
- </div>
- <script>
- (function() {
- let r = player.offsetWidth / 2 - 8, total = 60;
- Array.from({length: total}).forEach((item,key) => {
- let rad0 = (Math.PI / 180) * 360 / total * key,
- rad1 = (Math.PI / 180) * (180 + (360 / total * key));
- item = document.createElement('li-zi');
- item.style.cssText += `
- --x0: ${r + r * Math.cos(rad0)}px;
- --y0: ${r + r * Math.sin(rad0)}px;
- --x1: ${r + r * Math.cos(rad1)}px;
- --y1: ${r + r * Math.sin(rad1)}px;
- --duration: ${2 + Math.random() * 3}s;
- --delay: -${Math.random() * 5}s;
- `;
- player.appendChild(item);
- });
- let mState = () => {
- aud.paused ? (papa.style.setProperty('--state','paused'), vid.pause()) : (papa.style.setProperty('--state','running'), vid.play());
- };
- aud.addEventListener('playing', mState, false);
- aud.addEventListener('pause', mState, false);
- player.onclick = () => aud.paused ? aud.play() : aud.pause();
- })();
- </script>
复制代码
|
|