Mode:
Duration:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<!DOCTYPE html>
<html>
<head>
<title>Moving Box</title>
<style>
#box { width:50px; height:50px; background:red; position:absolute; top:50px; left:0 }
</style>
</head>
<body>
<div id="box"></div>
<script>
let pos = 0
setInterval(() => {
pos += 5
document.getElementById("box").style.left = pos + "px"
if(pos > window.innerWidth) pos = 0
}, 100)
</script>
</body>
</html>Coding works best on desktop or with an external keyboard.