|
|

楼主 |
发表于 2023-3-5 09:15
|
显示全部楼层
帖子代码
- <style>
- #papa {
- --state: paused; --deg: 1turn;
- 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/1/twlw.jpg') no-repeat center/cover;
- box-shadow: 6px 3px 20px #000;
- user-select: none;
- position: relative;
- z-index: 1;
- }
- #btnFs {
- position: absolute;
- bottom: 20px;
- width: fit-content;
- height: fit-content;
- padding: 6px;
- border-radius: 6px;
- border: 2px solid lightblue;
- color: lightblue;
- text-shadow: 1px 1px 1px #000;
- display: none;
- cursor: pointer;
- }
- #mplayer {
- margin: 200px auto;
- background: tan;
- box-shadow: -10px -10px 30px black inset;
- border-radius: 50%;
- width: 40px;
- height: 40px;
- cursor: pointer;
- animation: rot linear 3s infinite var(--state);
- position: relative;
- }
- #mplayer::before, #mplayer::after {
- position: absolute;
- content: '';
- width: 40px;
- height: 40px;
- top: 50px;
- box-shadow:
- 100px 100px 30px red,
- -100px 100px 30px navy,
- 100px -100px 30px orange,
- -100px -100px 30px olive;
- animation: rot linear 3s infinite var(--state);
- }
- #mplayer::after { --deg: -2turn; top: -50px; }
- @keyframes rot { to { transform: rotate(var(--deg)); } }
- </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=1959116081.mp3" autoplay loop></audio>
- </div>
- <script>
- (function() {
- let fs = false, timerId;
- 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());
- 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>
复制代码
|
|