码迷,mamicode.com
首页 > 移动开发 > 详细

跟随鼠标移动效果

时间:2017-05-10 23:10:03      阅读:295      评论:0      收藏:0      [点我收藏+]

标签:img   javascrip   html   mouse   color   head   type   use   bsp   

<!doctype html>
<html>
<head>
    <title></title>
    <meta charset = "utf-8"/>
</head>
<style type="text/css">
#imgId{
     position:absolute;
}
</style>

<script type="text/javascript">
function move(evt){
    var img=document.getElementById("imgId");
    //动态改变图片的坐标(图片的style的left和top),让图片的坐标和鼠标的坐标一致;
    img.style.left=evt.clientX;
    img.style.top=evt.clientY;
 
    
}

</script>
<body onmousemove="move(event)">
    <img id="imgId" src="images/1.jpg">
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    <br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
    
  
</body>
</html>

 

跟随鼠标移动效果

标签:img   javascrip   html   mouse   color   head   type   use   bsp   

原文地址:http://www.cnblogs.com/ahu666/p/6838652.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!