本帖最后由 花简静 于 2024-8-18 15:18 编辑
<style>
#mydiv {
margin: 130px 0 30px calc(50% - 931px);
width: 1700px;
height: 900px;
background: url('https://pic.imgdb.cn/item/65f065449f345e8d039dcdfa.jpg') no-repeat center/cover;
box-shadow: 3px 3px 8px #000, 0 0 0 2px silver;
overflow: hidden;
z-index: 1;
position: relative;
}
#player {
position: absolute;
left: 10px;
top: 10px;
width: 160px;
height: 160px;
transition: 3s;
filter: invert(1) drop-shadow(0 0 24px ForestGreen);
cursor: pointer;
animation: rot 5s linear infinite var(--state);
}
#player:hover { filter: invert(.8) drop-shadow(0 0 24px red); }
#vid {
position: absolute;
bottom: 0;
width: 100%;
height: calc(100% + 100px);
object-fit: cover;
pointer-events: none;
mix-blend-mode: screen;
}
@keyframes rot { to { transform: rotate(360deg); } }
</style>
<div id="mydiv">
<video id="vid" src="https://img.tukuppt.com/video_show/2269348/00/14/66/5e5a2fd36a145.mp4" loop muted></video>
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=1989498115" autoplay loop></audio>
<img id="player" src="https://638183.freep.cn/638183/web/svg/3star-01.svg" alt="" />
</div>
<script>
(function() {
let timer = null, 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: '#mydiv'});
mydiv.onmousemove = function(e) {
clearTimeout(timer);
timer = setTimeout(function() {
if(e.target.id === 'player') return;
let x = e.offsetX | e.layerX, y = e.offsetY | e.layerY, sw = player.offsetWidth;
if(x < 0) x = 0;
if(x > mydiv.offsetWidth - sw) x = mydiv.offsetWidth - sw;
if(y < 0) y = 0;
if(y > mydiv.offsetHeight - sw) y = mydiv.offsetHeight - sw;
player.style.cssText += `left: ${x}px; top: ${y}px`;
}, 400);
}
let mState = () => aud.paused
? (mydiv.style.setProperty('--state','paused'), vid.pause())
: (mydiv.style.setProperty('--state','running'), vid.play());
aud.addEventListener('playing', mState);
aud.addEventListener('pause', mState);
player.onclick = () => aud.paused ? aud.play() : aud.pause();
})();
</script>
<br><br><br><br><br>
|