最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

jQuery實(shí)現(xiàn)鼠標(biāo)跟隨效果

 更新時(shí)間:2017年02月20日 10:39:29   作者:前端工程師_錢成  
本文主要分享了jQuery實(shí)現(xiàn)鼠標(biāo)跟隨效果的示例代碼。具有很好的參考價(jià)值,下面跟著小編一起來看下吧

所謂鼠標(biāo)跟隨,一般就是指鼠標(biāo)移到哪張圖片上,那該張圖片的放大圖片就會(huì)出現(xiàn),并且放大圖片會(huì)隨著鼠標(biāo)在該張圖片上移動(dòng)而移動(dòng)。

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title></title>
 <style>
  *{
   margin:0;
   padding:0;
  }
  img{
   border:none;
  }
  .box{
   width:660px;
   position: relative;
  }
  .box .mark{
   position: absolute;
   width: 400px;
   height: 300px;
   display: none;
  }
  .box .mark img{
   width: 100%;
  }
  .box img{
   width: 150px;
   float: left;
   margin:5px;
  }
 </style>
</head>
<body>
<div class="box" id="box">
 <img src="http://www.qdfuns.com/misc.php?mod=attach&genre=editor&aid=e95708d565639d99576ae7cb00729334" 
  realImg="http://www.qdfuns.com/misc.php?mod=attach&genre=editor&aid=5328802dc943fc046e109f70359add0a" alt=""/>
 <img src="http://www.qdfuns.com/misc.php?mod=attach&genre=editor&aid=9e5459a7c0098c27adf4bdd73889caa9" 
  realImg="http://www.qdfuns.com/misc.php?mod=attach&genre=editor&aid=846f4d1987765dc4cfd5a06fcdd2dcc1" alt=""/>
 <img src="http://www.qdfuns.com/misc.php?mod=attach&genre=editor&aid=3cd1c8e301007f0c94850139ac79cb5a" 
  realImg="http://www.qdfuns.com/misc.php?mod=attach&genre=editor&aid=747bf3f7092ebd2b0bf9fcd27e28bbe5" alt=""/>
 <img src="http://www.qdfuns.com/misc.php?mod=attach&genre=editor&aid=f391169b2cf678aa6fd253cf40d9821d" 
  realImg="http://www.qdfuns.com/misc.php?mod=attach&genre=editor&aid=fec8d2f20fad1f28d540337a831e89d0" alt=""/>
 <div id="mark" class="mark"><img src="" alt=""/></div>
</div>
<script src="http://s0.kuaizhan.com/res/skin/js/lib/jquery-2.0.3.min.js"></script>
<script>
 //1.鼠標(biāo)移入哪張圖片的時(shí)候,讓他對應(yīng)的大圖顯示;
 //2.當(dāng)鼠標(biāo)在img中移動(dòng)的時(shí)候,大圖跟著走;
 var $box=$('.box');
 var $aImg=$box.children('img');
 var $mark=$('.mark');
 var $offset=$box.offset();
 $aImg.mouseover(function(){
  //當(dāng)鼠標(biāo)移入每張圖片的時(shí)候,讓mark顯示,并且,讓mark里面的img標(biāo)簽,src屬性值為當(dāng)前這個(gè)圖片的realImg屬性上拿到的值;
  $mark.show().find('img').attr('src',$(this).attr('realImg'));
 });
 $aImg.mousemove(function(e){
  //拿鼠標(biāo)的x坐標(biāo),減去$box距離body的left位置;
  var left= e.clientX-$offset.left+10;
  var top= e.clientY-$offset.top+10;
  $mark.css({left:left,top:top})
 });
 $aImg.mouseout(function(){
  $mark.hide();
 })
</script>
</body>
</html>

以上就是本文的全部內(nèi)容,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,同時(shí)也希望多多支持腳本之家!

相關(guān)文章

最新評論

杂多县| 达尔| 大渡口区| 万年县| 偏关县| 岳普湖县| 白水县| 文登市| 刚察县| 丹棱县| 昌黎县| 偃师市| 临沧市| 晋中市| 潮州市| 西和县| 峡江县| 正阳县| 弥渡县| 富蕴县| 宜君县| 象州县| 吴旗县| 石渠县| 衡南县| 井冈山市| 盐亭县| 华阴市| 龙门县| 中西区| 临沂市| 龙州县| 梅河口市| 托克托县| 武清区| 江北区| 叙永县| 大新县| 芮城县| 五峰| 博爱县|