本帖最后由 花简静 于 2024-5-31 20:23 编辑
<style>
#papa { margin: 130px 0 20px calc(50% - 931px) ; width: 1700px; height: 900px; background: url('https://642303.freep.cn/642303/tu/20240531NS01.webp') no-repeat center/cover; box-shadow: 2px 2px 5px #333; overflow: hidden; z-index: 1; position: relative; }
.mama { position: absolute; left: 300px; bottom: 120px; width:80px; height: 80px; cursor: pointer; animation: rot 8s linear infinite var(--state); }
.mama:nth-of-type(2) { right: 100px; bottom: 220px;}
e-son { position: absolute; left: calc(50% - 2.5px); top:6px; width: 5px; height: 30px; border-radius: 100% 0; border: 1px solid gray; transform-origin: 50% 100%; transform: rotate(var(--deg)) translateY(-10px); background: hsla(var(--bg), 100%, 50%, .8); }
#vid { position: absolute; bottom: 0; width: 100%; height: calc(100% + 80px); object-fit: cover; mix-blend-mode: screen; opacity: .23;}
@keyframes rot { to { transform: rotate(360deg); } }
</style>
<div id="papa">
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=1810268291" autoplay loop></audio>
<video id="vid" src="https://img.tukuppt.com/video_show/7165162/00/20/67/5f33b039ec172.mp4" loop muted></video>
<div class="mama" id="ma"></div>
</div>
<script>
(function() {
Array.from({length: 6}).forEach((e,k) => {
e = document.createElement('e-son');
e.style.cssText += `--deg: ${60 * k}deg; --bg: ${Math.round(Math.random() * 360)};`;
ma.appendChild(e);
});
Array.from({length: 5}).forEach((item,key) => {
//定位+色相转换数据数组
var pos = [[1130, 520, 60], [800, 741, 125], [1500, 300, 180],[1400, 600, 200],[500, 600, 290]];
item = document.getElementById('ma');
var clone = item.cloneNode(true);
clone.id = 'ma' + key;
clone.onclick = () => ma.click();
clone.style.cssText += `
left: ${pos[key][0]}px;
top: ${pos[key][1]}px;
filter: hue-rotate(${pos[key][2]}deg);
`;
papa.appendChild(clone);
});
aud.onplaying = aud.onpause = () => {
papa.style.setProperty('--state', aud.paused ? 'paused' : 'running');
aud.paused ? vid.pause() : vid.play();
};
ma.onclick = () => aud.paused ? aud.play() : aud.pause();
})();
</script>
<Br><Br><Br><Br><Br><Br><Br>
|