|
|

楼主 |
发表于 2023-2-7 12:15
|
显示全部楼层
帖子代码
- <style>
- #papa {
- margin: 0 0 0 calc(50% - 593px);
- width: 1024px;
- height: 640px;
- background: gray url('https://638183.freep.cn/638183/t23/webp/wdpojx.webp') no-repeat center/cover;
- box-shadow: 3px 3px 20px #000;
- position: relative;
- z-index: 1;
- }
- #mplayer {
- --state: paused;
- position: absolute;
- width: 160px;
- height: 160px;
- left: 20%;
- top: 18%;
- border-radius: 50%;
- background: none;
- box-shadow: inset 0 0 80px hsla(120,66%,36%,.95);
- transform: rotate(45deg);
- cursor: pointer;
- }
- #mplayer::before, #mplayer::after {
- position: absolute;
- content: '';
- left: -10px;
- top: -10px;
- right: -10px;
- bottom: -10px;
- border: 4px solid green;
- clip-path: inset(90% 0% 0% 0%);
- animation: clip 8s infinite linear;
- animation-play-state: var(--state);
- }
- #mplayer::after {
- animation-delay: -4s;
- }
- @keyframes clip {
- 25% { clip-path: inset(0% 0% 0% 90%); border-color: green; }
- 50% { clip-path: inset(0% 0% 90% 0%); border-color: lightgreen; }
- 75% { clip-path: inset(0% 90% 0% 0%); border-color: pink; }
- 100% { clip-path: inset(90% 0% 0% 0%); border-color: darkgreen; }
- }
- </style>
- <div id="papa">
- <div id="mplayer"></div>
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=441618650.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 = () => mplayer.style.setProperty('--state', aud.paused ? 'paused' : 'running');
- aud.addEventListener('pause', () => mState());
- aud.addEventListener('play', () => mState());
- mplayer.addEventListener('click', () => {
- aud.paused ? aud.play() : aud.pause();
- });
- FS({
- pa: papa,
- set: 'color: snow; background: black; border: 2px solid snow; left: 20px; bottom: 20px;',
- });
- })();
- </script>
复制代码
|
|