首页 > 网站 > WEB开发 > 正文

多物体运动框架

2024-04-27 15:09:10
字体:
来源:转载
供稿:网友
<!DOCTYPE html><html><head><meta charset="UTF-8"><title>多物体运动框架</title><style>div{width: 100px; height: 50px; background: greenyellow; margin: 10px;}</style></head><body><div></div><div></div><div></div><script>   var timer=null;var aDiv=document.getElementsByTagName('div');function move(target,obj){clearInterval(obj.timer);obj.timer=setInterval(function(){var speed=(target-obj.offsetWidth)/10;speed=speed>0?Math.ceil(speed):Math.floor(speed);if(target==obj.offsetWidth){clearInterval(obj.timer);}else{obj.style.width=obj.offsetWidth+speed+'px';}},30);}for(var i=0;i<aDiv.length;i++){aDiv[i].timer=null;aDiv[i].onmouSEOver=function(){move(500,this);}aDiv[i].onmouseout=function(){move(100,this);}}</script></body></html>
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表