作者:popperw 时间: 2008-05-11 文档类型:原创 来自:蓝色理想
类似QQ窗口的抖动效果,只是觉得好玩 没什么技术含量。
运行代码框<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> #body{text-align:center;} #test{width:119px;position:absolute;margin:10px auto;height:114px;background:url(http://www.blueidea.com/articleimg/2008/05/5766/01.jpg) ;border:2px dotted red;} </style> <script type="text/javascript"></script> </head> <body> <div style='margin:10px 200px'> <div><input type="button" value="~~~让我抖抖吧~~" onclick="nn.start()" /></div> <div><input type="button" value="别抖了眼睛晕的很" onclick="nn.stop()" /></div> <div id="test"></div> </div> </body> </html> <script type="text/javascript"> var m=document.getElementById("test"); function SKclass (obj,Rate,speed) { var oL=obj.offsetLeft; var oT=obj.offsetTop; this.stop=null; this.oTime=null; this.state=0; var om=this; this.start=function(){ if(this.state==0){ ostart(); this.state=1; } else{alert("这样你受得了吗?")} } var ostart=function(){ if(parseInt(obj.style.left)==oL-2){ obj.style.top=oT+2+"px"; setTimeout(function(){obj.style.left=oL+2+"px"},Rate) } else{ obj.style.top=oT-2+"px"; setTimeout(function(){obj.style.left=oL-2+"px"},Rate) } om.oTime=setTimeout(function(){ostart()},speed); } this.stop=function(){ clearTimeout(om.oTime); this.state=0; } } var nn=new SKclass(m,20,50); </script> [Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
经典论坛交流:http://bbs.blueidea.com/thread-2854083-1-1.html
出处:蓝色理想 责任编辑:bluehearts
◎进入论坛网页制作、WEB标准化版块参加讨论,我还想发表评论。
蓝色理想版权申明:除部分特别声明不要转载,或者授权我站独家播发的文章外,大家可以自由转载我站点的原创文章,但原作者和来自我站的链接必须保留(非我站原创的,按照原来自一节,自行链接)。文章版权归我站和作者共有。
转载要求:转载之图片、文件,链接请不要盗链到本站,且不准打上各自站点的水印,亦不能抹去我站点水印。
特别注意:本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有,文章若有侵犯作者版权,请与我们联系,我们将立即删除修改。