|
|

楼主 |
发表于 2024-2-10 13:15
|
显示全部楼层
帖子代码
- <style>
- #papa { margin: 0 0 0 calc(50% - 593px); position: relative; width: 1024px; height: 640px; overflow: hidden; background: lightblue url('https://638183.freep.cn/638183/t24/jpg/iuyi.jpg') no-repeat center/cover; box-shadow: 2px 2px 12px #000; }
- .vid { position: absolute; top: -100px; width: 1024px; height: 500px; object-fit: cover; mix-blend-mode: screen; pointer-events: none; }
- .vid:nth-of-type(2) { transform: scale(1,-1); top: 400px; opacity: .56; }
- .vid:nth-of-type(3) { top: 60px; width: 1124px; height: 700px; }
- .player { position: absolute; left: -100px; width: 100px; cursor: pointer; animation: move 80s linear infinite var(--state); }
- .player:nth-of-type(1) { top: 20px; }
- .player:nth-of-type(2) { transform: scale(1,-1); bottom: 20px; opacity: .5; }
- @keyframes move { to { left: 1024px; } }
- </style>
- <div id="papa">
- <audio id="aud" src="https://music.163.com/song/media/outer/url?id=1805837542" autoplay loop></audio>
- <video class="vid" src="https://img.tukuppt.com/video_show/2269348/00/14/17/5e1ca4afd33e2.mp4" loop muted></video>
- <video class="vid" src="https://img.tukuppt.com/video_show/2269348/00/14/17/5e1ca4afd33e2.mp4" loop muted></video>
- <video class="vid" src="https://img.tukuppt.com/video_show/2629112/00/01/91/5b4d7c5becb5a.mp4" loop muted></video>
- <img class="player" alt="" src="https://638183.freep.cn/638183/small/kite.png" />
- <img class="player" alt="" src="https://638183.freep.cn/638183/small/kite.png" />
- </div>
- <script>
- var vids = document.querySelectorAll('.vid'), players = document.querySelectorAll('.player');
- var vidplay = (play) => vids.forEach(vid => play ? vid.play() : vid.pause());
- var mState = () => aud.paused ? (papa.style.setProperty('--state', 'paused'),vidplay(false)) : (papa.style.setProperty('--state', 'running'),vidplay(true));
- aud.addEventListener('pause', mState);
- aud.addEventListener('playing',mState);
- players.forEach(player => player.onclick = () => aud.paused ? aud.play() : aud.pause());
- </script>
复制代码
|
|