我正在尝试从屏幕顶部进行掉钱,当到达一定高度时该钱会消失。到目前为止,它在浏览器上看起来很酷,但是我有一个任务要使其适应其他设备。那是JavaScript代码: 请帮助我如何使用remove()方法在对象达到特定高度时将其删除,具体取决于设备的高度?预先谢谢你createMoney();
setInterval(createMoney, 200);
function creatMoney() {
const money = document.createElement('i');
money.classList.add('fa');
money.classList.add('fa-money');
money.style.left = Math.random() * window.innerWidth + 'px';
money.style.animationDuration = Math.random() * 3 + 2 + 's';
money.style.opacity = Math.random();
money.style.fontSize = Math.random() * 10 + 10 + 'px';
document.body.appendChild(money);
setTimeout(() => {
money.remove();
}, 5000)
}
0 个答案:
没有答案