|
|

楼主 |
发表于 2023-2-28 07:45
|
显示全部楼层
帖子代码
- <style>
- #papa {
- --state: paused;
- margin: -80px 0 0 calc(50% - 593px);
- display: grid;
- place-items: center;
- width: 1024px;
- height: 640px;
- background: lightblue url('https://638183.freep.cn/638183/t23/webp/fyix.webp') no-repeat center/cover;
- box-shadow: 6px 3px 20px #000;
- user-select: none;
- position: relative;
- z-index: 1;
- }
- #mplayer {
- position: absolute;
- width: fit-content;
- height: fit-content;
- top: 40px;
- cursor: pointer;
- }
- .ball {
- margin: 2px;
- width: 20px;
- height: 20px;
- border-radius: 50%;
- background: lightblue;
- opacity: .45;
- position: relative;
- display: inline-block;
- box-shadow: -4px -4px 4px blue;
- }
- #btnFs {
- position: absolute;
- bottom: 20px;
- width: fit-content;
- height: fit-content;
- padding: 6px;
- border-radius: 6px;
- border: 2px solid snow;
- color: snow;
- text-shadow: 1px 1px 1px #000;
- display: none;
- cursor: pointer;
- }
- @keyframes flash { to { box-shadow: 0 0 60px 20px blue, -2px -2px 8px snow inset; } }
- </style>
- <div id="papa">
- <div id="mplayer"></div>
- <div id="btnFs">全屏观赏</div>
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=1933216917.mp3" autoplay loop></audio>
- </div>
- <script>
- (function() {
- let total = 26, fs = false, timerId;
- for(i = 0; i < total; i++) {
- let span = document.createElement('span');
- span.className = 'ball';
- span.style.cssText += `
- animation: flash ${Math.random()}s infinite alternate var(--state);
- `;
- mplayer.appendChild(span);
- }
- let mState = () => papa.style.setProperty('--state', aud.paused ? 'paused' : 'running');
- mplayer.onclick = () => aud.paused ? aud.play() : aud.pause();
- aud.addEventListener('play', () => mState());
- aud.addEventListener('pause', () => mState());
- aud.addEventListener('ended', () => playNext());
- aud.addEventListener('error', () => {
- if(aud.error.code === 4) aud.src = 'http://www.kumeiwp.com/sub/filestores/2023/02/28/466426af58d0bcacee07591638ed5f9a.mp3';
- });
- papa.addEventListener('mousemove', (e) => {
- clearTimeout(timerId);
- btnFs.style.display = 'block';
- timerId = setTimeout('btnFs.style.display = "none"', 3000);
- });
- btnFs.addEventListener('click', () => fs ? document.exitFullscreen() : papa.requestFullscreen());
- document.addEventListener('fullscreenchange', () => document.fullscreenElement !== null ? (fs = true, btnFs.innerText = '退出全屏') : (fs = false, btnFs.innerText = '全屏观赏'));
- })();
- </script>
复制代码
|
评分
-
| 参与人数 1 | 威望 +50 |
金钱 +100 |
经验 +50 |
收起
理由
|
红影
| + 50 |
+ 100 |
+ 50 |
赞一个! |
查看全部评分
|