本帖最后由 花简静 于 2024-6-16 23:16 编辑
<style>
#tz { margin: 130px 0 30px calc(50% - 931px); width: 1700px; height: 900px; overflow: hidden; display: grid; place-items: center; position: relative; }
#tz::before { position: absolute; content: ''; width: var(--size); height: var(--size); background: linear-gradient(cyan, olive, orange, navy); animation: spin 12s linear infinite var(--state); }
#nr { position: absolute; padding: 10px; background: url('https://642303.freep.cn/642303/tu/20240608ty06.webp') no-repeat center/cover; inset: 6px; }
txt-box { position: absolute; display: grid; place-items: center; left: var(--xx); :120px;bottom:160px; width: 248px; height:248px; font: normal 60px sans-serif; color: Wheat; transition: .5s; cursor: pointer; animation: move 5s var(--delay) linear infinite alternate var(--state);opacity : .99;}
txt-box::after { position: absolute; content: ''; inset: -6px; content: url('https://642303.freep.cn/642303/za/xiaotu06080603.png'); border-radius: 50%; box-shadow: inset 0 0 30px Peru; transform: perspective(200px) rotateY(-60deg) rotateZ(0); animation: rot 5s var(--delay) linear infinite alternate var(--state); }
txt-box:hover { filter: hue-rotate(20deg) drop-shadow(0 -10px 30px white); }
#vid { position: absolute; left: 0; top: 0; left: 380px; width: 90%; height: 100%; object-fit: cover; mix-blend-mode: screen; pointer-events: none; opacity : .5;}
#bird { position: absolute; left: 1700px; top: -28px; mix-blend-mode: multiply; animation: fly linear 26s infinite var(--state); }
@keyframes move { to { bottom: 430px; } }
@keyframes rot { to { transform: perspective(200px) rotateY(60deg) rotateZ(360deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fly { to { left: -400px; } }
</style>
<div id="tz">
<div id="nr" data-tt=" ">
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=32640749" autoplay loop></audio>
<video id="vid" src="https://img.tukuppt.com/video_show/2418175/00/02/20/5b51fdb829b10.mp4" muted autoplay loop disablePictureInPichture></video>
<img id="bird" alt="" src="https://642303.freep.cn/642303/za/feiniao.gif" />
</div>
</div>
<script>
(function() {
tz.style.setProperty('--size', Math.ceil(Math.sqrt(tz.offsetWidth ** 2 + tz.offsetHeight ** 2)) + 'px');
const ar = nr.dataset.tt.split('');
const total = ar.length, half = Math.floor(ar.length / 2);
let tbAr = [];
ar.forEach((t,k) => {
let tbox = document.createElement('txt-box');
tbox.textContent = t;
tbox.style.cssText += `
--xx: ${400 * k + 1000}px;
--delay: -${k <= half ? k * 0.5 : (total - k) * 0.5}s;
`;
tbAr.push(tbox);
nr.appendChild(tbox);
});
aud.onplaying = aud.onpause = () => {
tz.style.setProperty('--state', ['running','paused'][+aud.paused]);
aud.paused ? vid.pause() : vid.play();
tbAr.forEach(item => item.title = ['暂停','播放'][+aud.paused]);
};
tbAr.forEach(item => item.onclick = () => aud.paused ? aud.play() : aud.pause());
})();
</script>
|