Javascript物体运动(单物体运动)
来源:互联网 发布:农村淘宝在哪里 编辑:程序博客网 时间:2024/04/29 03:42
Javascript物体运动(单物体运动)
//侧边栏分享示例<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>运动动画效果</title> <style> *{margin:0px;padding: 0px;font-size: 14px;clear: both;} #div1{ width: 200px; height: 200px; background-color: red; opacity: 0.3; filter:alpha(opacity:30);//设置图层透明度 left: -200px; position: relative; top: 0px; } #share{ width: 20px; height: 50px; background-color: blue; font-family: '微软雅黑'; position: absolute; left: 200px; text-align: center; top: 75px; }</style><script>/** * 描述物体进行运动的状态 * @return {startMove(itarget);} 运动函数 */window.onload = function(){ var oDiv = document.getElementById('div1'); oDiv.onmouseover = function(){ startMove(0); } oDiv.onmouseout = function(){ startMove(-200); }}//获取idfunction getdiv(){ var oDiv = document.getElementById('div1');}var timer = null;function startMove(itarget,fn){ var oDiv = document.getElementById('div1'); // getdiv(); clearInterval(timer); timer = setInterval(function(){ var speed = 0; if(oDiv.offsetLeft > itarget){ speed = -10; }else if(oDiv.offsetLeft < itarget){ speed = 10; }else{ speed = 0; } oDiv.style.left = oDiv.offsetLeft + speed +'px'; }, 30);}</script></head><body><div id="div1"><span id='share'>分享</span></div></body></html>
Javascript物体运动(单物体运动)
//侧边栏分享示例<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>运动动画效果</title> <style> *{margin:0px;padding: 0px;font-size: 14px;clear: both;} #div1{ width: 200px; height: 200px; background-color: red; opacity: 0.3; filter:alpha(opacity:30);//设置图层透明度 left: -200px; position: relative; top: 0px; } #share{ width: 20px; height: 50px; background-color: blue; font-family: '微软雅黑'; position: absolute; left: 200px; text-align: center; top: 75px; }</style><script>/** * 描述物体进行运动的状态 * @return {startMove(itarget);} 运动函数 */window.onload = function(){ var oDiv = document.getElementById('div1'); oDiv.onmouseover = function(){ startMove(0); } oDiv.onmouseout = function(){ startMove(-200); }}//获取idfunction getdiv(){ var oDiv = document.getElementById('div1');}var timer = null;function startMove(itarget,fn){ var oDiv = document.getElementById('div1'); // getdiv(); clearInterval(timer); timer = setInterval(function(){ var speed = 0; if(oDiv.offsetLeft > itarget){ speed = -10; }else if(oDiv.offsetLeft < itarget){ speed = 10; }else{ speed = 0; } oDiv.style.left = oDiv.offsetLeft + speed +'px'; }, 30);}</script></head><body><div id="div1"><span id='share'>分享</span></div></body></html>
阅读全文
0 0
- Javascript物体运动(单物体运动)
- JavaScript物体运动一
- JavaScript物体运动二
- JavaScript物体运动三
- js运动-改变透明度(单物体)
- JavaScript运动框架(三):多物体任意值运动
- javascript运动框架多物体运动---1
- javascript运动框架多物体运动---1
- js运动-多物体运动
- javascript 多物体任意运动框架
- JavaScript多物体运动及函数封装
- javascript动画特效 多物体运动 源代码
- 42、JavaScript的运动----多个物体同时运动
- Javascript运动概念2——多物体运动框架
- 简易物体运动
- 物体的阻尼运动
- 多物体运动
- 多物体运动
- App Inspector使用简介
- 如何进行Java开发
- LeetCode
- struts2三
- docker 笔记(1)
- Javascript物体运动(单物体运动)
- springMVC+CAs+shiro整合一 环境搭建下载CAS及导入idea中
- Tomcat 优化前后的性能对比
- Java8系列--并行流与并行流的性能测试
- 《机器学习》读书笔记 7 第5章 神经网络 二
- 修改Windows系统同步网络时间的频率
- 将MyEclipse项目添加到SVN中
- hdu 4799 LIKE vs CANDLE. 树形dp
- Linux USB设备驱动程序设计 和 USB下载线驱动设计