<div class="emoji"> </div>
.emoji {
width: 30px;
height: 30px;
background-image: url(http://img.cdn.sugarat.top/mdImg/MTU4NDE1NjM1Nzg2Mg==584156357862);
background-size: 90px 90px;
background-position: 0 0;
}
function rand() {
return (~~(Math.random() * 100) % 3) * 30;
}
let $emoji = document.querySelector(".emoji");
function loop() {
let x = rand();
let y = rand();
$emoji.style.backgroundPosition = `${x}px ${y}px`;
// 500ms
setTimeout(loop, 500);
}
loop();
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.