您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

javascript实现图片左右移动的方法

2025/10/11 20:04:13发布24次查看
图片的左右移动,具备像荡秋千一样的动画效果,图片自己可重新定义,移动速度和距离也可在代码内设定,挺简单的js生成动画的特效代码,仅供参考。
<!doctype html> <html> <head> <meta charset="utf-8"> <title>自定义动画</title> <script type="text/javascript" src="jquery.1.12.4.js"></script> <style> * { margin: 0; } </style> <script type="text/javascript"> var movetoleft = function () { $("#topimg").animate( { "left": "0" } , "slow", movetoright); } ; var movetoright = function () { $("#topimg").animate( { "left": "100px" } , "slow", movetoleft); } ; $(function () { $("button").click(movetoright); } ); </script></head><body><button>点击我右移100px</button><br/><br/><br/><br/><img id="topimg" style="position: absolute; left: 0" src="图片1_30.jpg"/></body></html>
以上就是javascript实现图片左右移动的方法的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product