1、使方块移动

源码 :

<script type="text/javascript">
    var div = document.createElement('div');
    document.body.appendChild(div);
    div.style.width = "100px";
    div.style.height = "100px";
    div.style.background = "red";
    div.style.position = "absolute";
    div.style.left =  "0px";
    div.style.top = "0px";

    //每隔50毫秒执行该函数。
    setInterval(function(){
        div.style.left = parseInt(div.style.left) + 5  + "px";
        div.style.top =  parseInt(div.style.top)  + 5  + "px";
    },50);
</script>

截图:

js实现动画(移动方块)

 

相关文章:

  • 2022-12-23
  • 2021-10-07
  • 2022-01-07
  • 2021-11-13
  • 2021-07-05
  • 2021-08-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-11
  • 2021-08-19
  • 2021-08-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案