代码超少的Div弹性运动特效,点击按钮后,Div层来回做运动,像有弹性一样在缓冲,动感十足的样子。 关于类似的例子,烈火学院以前给大家介绍了几个,我们可以来回顾一下。 一。JS编写透明度渐变、位置移动等多个函数 二。js+css 完成一个漂亮的、富有弹性的导航菜单 演示: <!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> <title>div移动</title> <style type="text/css"> #div1{ background: #FFCC66; border:#FF6600 1px solid; height:100px; width:100px; position:relative; left:0px;} </style> <script type="text/javascript"> var t=null; function startMove() { if(t) { clearInterval(t); } t=setInterval(move, 30); } var step=0; function move() { var odiv=document.getElementById("div1"); step+=(100-odiv.offsetLeft)/50; step=step*0.98 odiv.style.left=odiv.offsetLeft+step; } </script> </head> <body> <div id="div1"> </div> <input type="button" value="移动" onclick="startMove()"/> </body> </html><br /><center>如不能显示效果,请按Ctrl+F5刷新本页,更多网页代码:<a href='http://www.veryhuo.com/' target='_blank'>http://www.veryhuo.com/</a></center>提示:可修改后代码再运行! 文章导航 CSS+Js的纵向导航菜单,滑动展开的列表效果纯CSS带箭头阴影的提示框代码,不兼容IE