|
|

楼主 |
发表于 2023-3-1 07:43
|
显示全部楼层
帖子代码
- <style>
- #papa {
- --state: paused;
- --s1: 0.8; --s2: 1.6;
- 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/iyyb.webp') no-repeat center/cover;
- box-shadow: 6px 3px 20px #000;
- user-select: none;
- position: relative;
- z-index: 1;
- }
- #papa:fullscreen { --s1: 1; --s2: 2; }
- #papa:fullscreen .ball { width: 20px; height: 20px; }
- #mplayer {
- position: absolute;
- width: 140px;
- height: 140px;
- display: grid;
- place-items: center;
- cursor: pointer;
- animation: change 10s linear infinite alternate var(--state);
- }
- .ball {
- position: absolute;
- width: 15px;
- height: 15px;
- border-radius: 50%;
- box-shadow: -5px 0 10px hsla(0,0%,0%,.42) inset;
- }
- #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 100px 30px hsla(200, 100%,50%, .35), -2px -2px 8px snow inset; } }
- @keyframes change { from { transform: rotate(0) scale(var(--s1)); } to { transform: rotate(1turn) scale(var(--s2)); } }
- </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=1858415053.mp3" autoplay loop></audio>
- </div>
- <script>
- (function() {
- let total = 18, fs = false, timerId;
- for(let i = 0; i < total; i ++) {
- let ball = document.createElement('span');
- ball.className = 'ball';
- ball.style.cssText += `
- background: #${Math.random().toString(16).substr(-6)};
- transform: rotate(${360/total*i}deg) translate(70px);
- animation: flash ${Math.random()+0.1}s infinite alternate var(--state);
- `;
- mplayer.appendChild(ball);
- }
- 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/03/01/c6bc152cd2954d79cff5da3a7adba48d.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 |
赞一个! |
查看全部评分
|