|
|

楼主 |
发表于 2023-3-3 12:30
|
显示全部楼层
帖子代码
- <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/yvui.webp') no-repeat center/cover;
- box-shadow: 6px 3px 20px #000;
- user-select: none;
- position: relative;
- z-index: 1;
- }
- #papa::before {
- position: absolute;
- content: '';
- width: 200px;
- height: 200px;
- background: transparent;
- box-shadow: var(--boxsd);
- border-radius: 50%;
- }
- #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 18s 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 60px hsla(240, 100%,50%, .2), -2px -2px 8px snow inset; } }
- @keyframes change {
- from { transform: perspective(3000px) translateZ(-360px) rotateX(-15deg) rotateY(-30deg) rotateZ(0) scale(var(--s1)); }
- to { transform: perspective(3000px) translateZ(360px) rotateX(15deg) rotateY(30deg) rotateZ(3turn) 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=1893368015.mp3" autoplay loop></audio>
- </div>
- <script>
- (function() {
- let total = 18, fs = false, timerId, boxTimer;
- 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 flash = () => {
- clearTimeout(boxTimer);
- papa.style.setProperty('--boxsd', `
- ${Math.random()*100 - 500}px 0 60px #${Math.random().toString(16).substr(-6)},
- ${Math.random()*100 - 350}px 0 60px #${Math.random().toString(16).substr(-6)},
- ${Math.random()*100 + 250}px 0 60px #${Math.random().toString(16).substr(-6)},
- ${Math.random()*100 + 400}px 0 60px #${Math.random().toString(16).substr(-6)}`);
- boxTimer = setTimeout(flash,120);
- };
- let mState = () => aud.paused ? (papa.style.setProperty('--state','paused'), clearTimeout(boxTimer)) : (papa.style.setProperty('--state','running'), flash());
- mplayer.onclick = () => aud.paused ? aud.play() : aud.pause();
- aud.addEventListener('play', () => mState());
- aud.addEventListener('pause', () => mState());
- aud.addEventListener('ended', () => playNext());
- 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 |
赞一个! |
查看全部评分
|