首页 > 其他 > 详细

弹性运动

时间:2015-04-27 11:20:17      阅读:114      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
  <html>
  <head lang="en">
  <meta charset="UTF-8">
  <style type="text/css">
  #box{width:100px;height:100px;background:red;position: absolute;left:0;}
  span{height:900px;border-left:1px red solid;position: absolute;left:500px;}
  </style>
  <title></title>
  <script type="text/javascript">
  window.onload=function()
  {
  var oInput=document.getElementById("input1");
  var oDiv=document.getElementById("box");
  var timer=null;
  oInput.onclick=function()
  {
  startMove();
  };
  function startMove()
  {
  clearInterval(timer);
  var iSpeed=0;
  timer=setInterval(function()
  {
  if(oDiv.offsetLeft<500)
  {
  iSpeed+=5;
  }
  else
  {
  iSpeed-=5;
  }
  oDiv.style.left=oDiv.offsetLeft+iSpeed+"px";
  },30)
  }
  }
  </script>
  </head>
  <body>
  <input type="button" value="开始运动" id="input1"/>
  <div id="box"></div>
  <span></span>
  </body>
  </html>

弹性运动

原文:http://blog.csdn.net/xiaomogg/article/details/45306475

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!