<html> <head> <title>Singularity</title> <style> body { background-color: grey; } #boxOne { position:relative; height:150px; width:150px; background-color: black; } </style> <script> function playOne(){ document.getElementById("boxOne").style.left = "30px"; document.getElementById("boxOne").style.transition = "all 4s"; } </script> </head> <body> <div id="boxOne" onclick="playOne()"></div> </body> </html>
The above code works the same as a field moving left to right. I used style.transition successfully to move the circle slowly from left to right, but this field does not behave the way I'm trying to get it. The box should not instantly move from left to right, it should take 4 seconds, as indicated in the style.transition script. I donโt understand what I am doing wrong.
source share