<!DOCTYPE html>
<html>
<head>
<style type="text/css">
div{
height: 100px;
width: 100px;
background-color
urple;
}
</style>
<script>
addEventListener('DOMContentLoaded',
function() {
const elem = document.querySelector('div'),
size = [innerWidth - 100, innerHeight - 100],
random = a => a * Math.random()|0,
timer = () => {
const [left, top] = size.map(random);
elem.style.transform = `translate(${left}px, ${top}px`;
};
elem.addEventListener('click',timer)
});
</script>
</head>
<body bgcolor = black;>
<div></div>
</body>
</html>