|
|

楼主 |
发表于 2023-12-25 12:17
|
显示全部楼层
帖子代码
- <style>
- #papa {
- margin: 10px 0 10px calc(50% - 721px);
- width: 1280px;
- height: 720px;
- background: url('https://638183.freep.cn/638183/t23/webp2/glri.webp') no-repeat center/cover;
- box-shadow: 3px 3px 20px #000;
- overflow: hidden;
- display: grid;
- place-items: center;
- position: relative;
- z-index: 1;
- }
- #mypic {
- position: absolute;
- mix-blend-mode: exclusion;
- cursor: pointer;
- transition: filter 1s;
- animation: rot 6s infinite linear var(--state);
- }
- #mypic:hover {
- filter: invert(100%) drop-shadow(4px 4px 20px snow);
- }
- li-zi {
- position: absolute;
- width: 50px;
- height: 1px;
- background: linear-gradient(to right,snow,yellow);
- animation: moving var(--du) var(--de) infinite linear var(--state);
- }
- @keyframes moving {
- from { transform: translate(0,0) rotate(var(--deg)); opacity: 0; }
- to { transform: translate(var(--xx),var(--yy)) rotate(var(--deg)); opacity: 1; }
- }
- @keyframes rot { to { transform: rotate(360deg); } }
- </style>
- <div id="papa">
- <img id="mypic" src="https://638183.freep.cn/638183/t23/btn/12f.png" alt="" title="暂停/播放" />
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=26178034" autoplay loop></audio>
- </div>
- <script>
- let total = 160;
- Array.from({length: total}).forEach((lz,key) => {
- lz = document.createElement('li-zi');
- let hudu = Math.PI / 180 * 360 / total * key;
- let xx = 800 * Math.cos(hudu), yy = 800 * Math.sin(hudu);
- lz.style.cssText += `
- --xx: ${xx}px;
- --yy: ${yy}px;
- --deg: ${360 / total * key}deg;
- --du: ${2 + Math.random() * 2}s;
- --de: -${Math.random() * 3}s;
- `;
- papa.prepend(lz);
- });
- let mState = () => papa.style.setProperty('--state', aud.paused ? 'paused' : 'running');
- aud.addEventListener('pause', () => mState());
- aud.addEventListener('playing', () => mState());
- mypic.onclick = () => aud.paused ? aud.play() : aud.pause();
- </script>
复制代码
|
|