|
|

楼主 |
发表于 2022-7-15 13:16
|
显示全部楼层
添加或改进过的代码用红色标志:
<style>
#papa { left: -352px; width: 1300px; height: 758px; background: blue url('https://pic.imgdb.cn/item/62d0df28f54cd3f937c14326.jpg') no-repeat center/cover; box-shadow: 4px 4px 24px #000; position: relative; }
#hunter { position: absolute; width: 122px; height: 147px; transition: left 3s, top 3s; z-index: 99; }
#prey { position: absolute; width: 240px; height: 240px; border-radius: 50%; }
#btnplay { position: absolute;left: 20px; top: 20px; width: 30px; height: 30px; cursor: pointer; border: none; outline: none; border-radius: 50%; }
#btnplay:hover { color: red; box-shadow: 1px 1px 1px #000; }
#lrcbox { position: absolute;left: 60px;top: 20px;font: normal 1.2em / 1.6em '宋体', sans-serif;color: snow;text-shadow: 1px 1px 2px #000; }
</style>
<div id="papa">
<input id="btnplay" type="button" value=">" />
<div id="lrcbox">LRC LOADING ...</div>
<img id="hunter" alt="" src="https://pic.imgdb.cn/item/6247e3c027f86abb2a56f17a.gif" />
<img id="prey" src="https://pic.imgdb.cn/item/62d0e127f54cd3f937c47bb3.jpg" alt="" />
</div>
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=1948069356.mp3" autoplay="autoplay" loop="loop"></audio>
<script>
let last = 0;
let lrcAr = [
['0.00','曲名 : 清凉音乐'],
['5.00','歌手 : 休闲 Maestro'],
['10.00','帖名 : 纯音乐'],
['160.00','谢谢欣赏 ']
];
let num = (min, max) => Math.floor(Math.random() * (max-min+1)) + min;
setTimeout(gogo,100);
btnplay.onclick = () => aud.paused ? aud.play() : aud.pause();
aud.addEventListener('playing', () => btnplay.value = '||');
aud.addEventListener('pause', () => btnplay.value = '>');
aud.addEventListener('timeupdate',function(){
let tt = aud.currentTime;
for(j=0; j<lrcAr.length; j++){
if(tt >= lrcAr[j][0]) lrcbox.innerHTML = lrcAr[j][1];
}
});
function gogo() {
let left = num(50,1050), top = num(420,518);
hunter.style.transform = last < left ? 'scale(1,1)' : 'scale(-1,1)';
prey.style.left = left + 'px';
prey.style.top = top + 'px';
hunter.style.left = left + 45 + 'px';
hunter.style.top = top - 100 + 'px';
last = left;
setTimeout(gogo,6000);
}
</script>
|
|