朵拉 发表于 2024-3-13 20:07

小 宝(马黑黑原创)

本帖最后由 朵拉 于 2024-3-13 20:14 编辑 <br /><br /><style>
    #papa { margin: 30px 0 0 calc(50% - 593px); width: 1024px; height: 640px; background: cyan url('https://pic.imgdb.cn/item/65f197959f345e8d03d06e7b.jpg') no-repeat center/cover; box-shadow: 3px 3px 20px #000; position: relative; z-index: 1; }
    #btnplay { position: absolute; left: 10px; top: 10px; width: 80px; height: 80px; border: 2px dotted cyan; border-radius: 50%; box-shadow: inset 0 0 20px #00ffff; transition: 6s; animation: rot 8s linear infinite var(--state); }
    #papa:fullscreen #btnplay { width: 150px; height: 150px; }
    #papa video { position: absolute; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; opacity: .6; mix-blend-mode: darken; pointer-events: none; }
    #papa > video { border-radius: 0 30% 0 0; mix-blend-mode: normal; filter: opacity(.35); }
    @keyframes rot { to { transform: rotate(360deg); } }
</style>

<div id="papa">
    <audio id="aud" src="https://music.163.com/song/media/outer/url?id=1863623907" autoplay loop></audio>
    <video src="https://img.tukuppt.com/video_show/2475824/00/02/16/5b53eaca0f2f5.mp4" loop muted></video>
    <div id="btnplay">
      <video id="vid" src="https://img.tukuppt.com/video_show/15653652/01/01/65/6126376f1df40.mp4" loop muted></video>
    </div>
</div>

<script>
    (function() {
      let sF = document.createElement('script');
      sF.src = 'https://638183.freep.cn/638183/web/api/fullscreen.js';
      sF.charset = 'utf-8';
      document.querySelector('body').appendChild(sF);
      sF.onload = () => FS({papa: '#papa', css: '--bg: transparent; --color: cyan; bottom: 10px; left: 48%;'});
      let playVideo = (flag) => { let vids = document.querySelectorAll('#papa video'); vids.forEach(vid => { flag ? vid.play() : vid.pause(); }); };
      let mState = () => aud.paused ? (papa.style.setProperty('--state','paused'),btnplay.title = '点击播放',vid.pause(),playVideo(false)) : (papa.style.setProperty('--state','running'),btnplay.title = '点击暂停',vid.play(),playVideo(true));
      let getOffsetPos = (ele) => { let x = ele.offsetLeft, y = ele.offsetTop, pa = ele.offsetParent; while(pa != null) { x += pa.offsetLeft; y += pa.offsetTop; pa = pa.offsetParent; } return {x, y}; };
      aud.onplaying = aud.onpause = () => mState();
      btnplay.onclick = () => aud.paused ? aud.play() : aud.pause();
      let movTimer = null, paWidth = papa.clientWidth, sonSize = btnplay.clientWidth, bodyWidth = document.body.clientWidth, paOffset = getOffsetPos(papa).x;
      document.onmousemove = function(e) {clearTimeout(movTimer); movTimer = setTimeout(function() { if (e.target.id === "btnplay" || e.target.id == 'btnFs') return; if (document.fullscreenElement === null) { let x = e.pageX; if (x < paOffset) x = paOffset; x = x - paOffset; if (x + sonSize >= paWidth) x = paWidth - sonSize; btnplay.style.cssText += `left: ${x}px;`; } else { let xx = e.offsetX || e.layerX; if (xx + sonSize > bodyWidth) xx -= sonSize; btnplay.style.cssText += `left: ${xx - 75}px;`; } }, 400); };
    })();
</script>

朵拉 发表于 2024-3-13 20:14

@马黑黑
老师 晚上好,学生交作业,请指正哈{:4_190:}

马黑黑 发表于 2024-3-13 20:33

厉害

红影 发表于 2024-3-13 21:09

漂亮,欣赏朵宝好帖{:4_187:}
页: [1]
查看完整版本: 小 宝(马黑黑原创)