<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>老鹰捉小鸡</title> <style> img{width:30px;height:30px;position:absolute;} </style> <script> function getPos(ev) { var scrollLeft=document.documentElement.scrollLeft||document.body.scrollLeft; var scrollTop=document.documentElement.scrollTop||document.body.scrollTop; return{x:ev.clientX+scrollLeft,y:ev.clientY+scrollTop}; } document.onmousemove=function(ev) { var oEvent=ev||event; var aDiv=document.getElementsByTagName("img"); for(var i=aDiv.length-1;i>0;i--){ aDiv[i].style.left=aDiv[i-1].offsetLeft+'px'; aDiv[i].style.top=aDiv[i-1].offsetTop+'px'; } aDiv[0].style.left=getPos(oEvent).x+'px'; aDiv[0].style.top=getPos(oEvent).y+'px'; } </script> </head> <body> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> <img src="images/小黄鸡.jpg"> </body> </html>