Rashed Hossain
Rashed Hossain

Reputation: 1

javascript animation not showing

I have done this code with javascript to try out my first javascript animation, but when I open the page, it's showing me a blank page...

can anyone please tell me whats wrong with the code and why it's not showing anything?

thanks in advance...

<html>
<head>
<title>Trying js Animation</title>
</head>
<body>
<style>
  #container{
    width: 500px;
    height: 500px;
    color: green;
    position: relative;
  }
  #box{
    width: 50px;
    height: 50px;
    color: red;
    position: absolute;
  }
</style>
<div id="container">
  <div id="box">
  </div>
</div>
<script type="text/javascript">
  var t = setInterval(move, 1);
  var pos = 0;
  var box = document.getElementById('box');
  function move(){
    pos += 1;
    box.style.left = pos + "px";
  }
</script>
</body>
</html>

Upvotes: 0

Views: 104

Answers (1)

mab
mab

Reputation: 810

The box is white. Change "color" to "background-color".

Upvotes: 2

Related Questions