2012-02-27 5 views
0

このサイトのvideonツールヒントとマウスオーバー時の定位置を保持しますか?

私は親画像が上に乗っているときに別の画像を表示するツールチップスクリプトを実装しました。ツールチップイメージは、親イメージの上に直接中央揃えされていませんが。

誰もが、私はツールチップの画像は、それの親を介してセンターを登場させるために変更する必要があるかについての洞察を提供することができますか?ここで

// Load this script once the document is ready 
    $(document).ready(function() { 

     // Get all the thumbnail 
     $('div.thumbnail-item').mouseenter(function(e) { 

      // Calculate the position of the image tooltip 
      x = e.pageX - $(this).offset().left; 
      y = e.pageY - $(this).offset().top; 

      // Set the z-index of the current item, 
      // make sure it's greater than the rest of thumbnail items 
      // Set the position and display the image tooltip 
      $(this).css('z-index','101') 
      .children("div.tooltip") 
      .css({'top': y + -400,'left': x + -115,'display':'block'}); 

     //}).mousemove(function(e) { 

      // Calculate the position of the image tooltip   
     // x = e.pageX - $(this).offset().left; 
     // y = e.pageY - $(this).offset().top; 

      // This line causes the tooltip will follow the mouse pointer 
     // $(this).children("div.tooltip").css({'top': y + -400,'left': x + -105}); 

     }).mouseleave(function() { 

      // Reset the z-index and hide the image tooltip 
      $(this).css('z-index','100') 
      .children("div.tooltip") 
      .animate({"opacity": "hide"}, "fast"); 
     }); 

    }); 
+0

はたぶん、あなたは現在、私たちの時間を節約するためにツールチップを配置するために使用することをここに私たちのコードを示すことができる幅が中心となります。 – Lycha

答えて

0

は計算でマウスイベントの位置を使用しないでください...ツールチップに電力を供給するJavaScript関数です。左手の親指オフセット()。プラス1/2それは

関連する問題