队长又做时间代码了,真好,温故而知新
是啊,把原来做过的全部再做一次。
<style>
#papa { margin: 50px auto 0; width: 720px; height: 600px; background: #333 url('https://pic.imgdb.cn/item/62c990c5f54cd3f937271919.gif') no-repeat center/cover;
#hunter { position: absolute; width: 90px; height: 66px; transition: all 3s; z-index: 99; }
#prey { position: absolute; width: 60px; height: 60px; background: #333 linear-gradient(120deg,purple,tan); border-radius: 50%; }
</style>
<div id="papa">
<imgid="hunter" alt="" src="/data/attachment/forum/202207/08/225900jzc7ctq9wa99r83a.gif" />
<span id="prey"></span>
</div>
<audio id="aud" src="https://music.163.com/song/media/outer/url?id=1840007566.mp3" autoplay="autoplay" loop="loop"></audio>
<script>
let aniFlag = 1;
let num = (min, max) => Math.floor(Math.random() * (max-min+1)) + min;
setTimeout(gogo,100);
function gogo() {
let left = num(0,960), top = num(0,500);
prey.style.left = left + 'px';
prey.style.top = top + 'px';
hunter.style.left = left + 'px';
hunter.style.top = top + 'px';
aniFlag == 1 ? (prey.style.opacity = '1', aniFlag = 0) : (prey.style.opacity = '0', aniFlag = 1);
setTimeout(gogo,6000);
}
</script>
页:
1
[2]