匀速运动
来源:互联网 发布:人工智能的文献综述 编辑:程序博客网 时间:2024/06/07 01:23
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Document</title> <style> div{ width:100px; height:100px; background-color:red; position:absolute; height:100px; left:500px } </style></head><body style="height:2000px;"> <script> window.onload=function () { var timer=null; function startMove(target) { var speed=10; clearInterval(timer); var oDiv=document.getElementById('div'); timer=setInterval(function () { if(oDiv.offsetLeft<target){ speed=7; }else{ speed=-7; } if(Math.abs(oDiv.offsetLeft-target)<7){ //是否到达终点 clearInterval(timer); //到达终点后 oDiv.style.left=target+'px'; }else{ oDiv.style.left=oDiv.offsetLeft+speed+'px';//到达终点前 } },30) } var oInput=document.getElementById('button'); oInput.addEventListener('click',function(){ startMove(300); },false) } </script> <input type="button" value="开始运动" id="button"> <div id="div"></div> <span style="width:1px;height:300px;position:absolute;left:300px;top:0;background:black;"></span></body></html>
0 0
- 匀速运动
- 匀速运动
- 匀速运动
- JS匀速运动
- js匀速运动
- 物体匀速运动的实现
- Box2D C++ 教程-匀速运动
- Box2D C++ 匀速运动
- 匀速运动之停止条件
- 匀速运动实例---分享到
- JavaScript 运动之匀速运动
- Canvas基本匀速运动
- Box2D C++ 教程-匀速运动
- 匀速运动小问题
- js运动技术--匀速运动
- 匀速运动(js)
- JavaScript 动画之匀速运动
- javascript动画之匀速运动
- Apache kafka 工作原理介绍
- 新浪微博发布效果
- 浮动框架iframe元素
- 从零开始学网络爬虫之BeautifulSoap
- 快速认识ELK中的L - Logstash
- 匀速运动
- 图书管理系统
- 伸缩菜单
- Hadoop平台中SQL优化的四个思路
- 从中心放大
- c++ 中__declspec 的用法
- 第十五周OJ——2886大写变小写
- Java被忽略的基本知识(一)
- Java/Android 常面面试题抽取