|
|

楼主 |
发表于 2023-2-12 17:21
|
显示全部楼层
帖子代码
- <style>
- #papa {
- --state: paused;
- margin: 80px 0 0 calc(50% - 593px);
- width: 1024px;
- height: 640px;
- background:url('https://638183.freep.cn/638183/t23/webp/uqwm.webp') no-repeat center/cover;
- box-shadow: 3px 3px 20px #000;
- display: grid;
- place-items: center;
- position: relative;
- z-index: 1;
- }
- #mplayer {
- position: absolute;
- left: calc(50% - 100px);
- top: 40px;
- width: 200px;
- height: 200px;
- border-radius: 50%;
- background: linear-gradient(to right top,black,red,teal);
- box-shadow: -50px -50px 100px #eee inset, 0 0 200px #fff;
- cursor: pointer;
- animation: rot 8s linear infinite var(--state);
- }
- @keyframes rot { to { transform: rotate(360deg); } }
- </style>
- <div id="papa">
- <div id="mplayer"></div>
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=521228147.mp3" autoplay loop></audio>
- </div>
- <script>
- (function() {
- (function(mkFS) {let setFullScreen = (user_set) => {let pa = user_set.pa;if(typeof(pa) !== 'object') return false;if(!user_set.set) user_set.set = 'color: snow; background: black; border: 2px solid snow; left: 40px; bottom: 40px;';btnMsg = document.createElement('span');btnMsg.style.cssText = `position: absolute; border-radius: 8px; padding: 4px; cursor: pointer; z-index:998; ${user_set.set}`;btnMsg.innerText = '全屏观赏';btnMsg.style.display = 'none';pa.appendChild(btnMsg);let timerId, fs = false;btnMsg.onclick = () => fs ? document.exitFullscreen() : pa.requestFullscreen();pa.addEventListener('mousemove', (e) => {clearTimeout(timerId);btnMsg.style.display = 'block';timerId = setTimeout('btnMsg.style.display = "none"', 3000);});document.addEventListener('fullscreenchange', () => {if (document.fullscreenElement !== null) {fs = true;btnMsg.innerText = '退出全屏';} else {fs = false;btnMsg.innerText = '全屏观赏';}});};mkFS.FS = setFullScreen;})(this);
- let mState = () => papa.style.setProperty('--state', aud.paused ? 'paused' : 'running');
- aud.addEventListener('play', () => mState());
- aud.addEventListener('pause', () => mState());
- mplayer.addEventListener('click', () => {
- aud.paused ? aud.play() : aud.pause();
- });
- FS({pa: papa, set: 'color: snow; background: none; border: 2px solid snow; bottom: 20px;',});
- })();
- </script>
复制代码
|
|