js图片跟随效果

<img src="love.jpg"  width="150" alt="">
	<script type="text/javascript">
	    var oImg = document.querySelector("img");
	    document.onmouseover=function(e){
	    	var e=e||event;
	    	var x=e.pageX;
	    	var y=e.pageY;
	    	oImg.style.left=x-oImg.width/2+"px";
	    	oImg.style.top=y-oImg.height/2+"px";
	    }
	</script>
posted @ 2019-01-03 10:57  lxystar  阅读(170)  评论(0编辑  收藏  举报