2012-02-27 51 views
0

在这个网站videon居中工具提示并按住mouseover?

我已经实现了一个工具提示脚本,它显示不同的图像时,它的父图像是悬停结束。虽然工具提示图像不直接居中在父图像上。

任何人都可以提供见解,我需要改变,使工具提示图像出现在它的父母的中心?

这里是JavaScript函数的工具提示供电...

// 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 2012-02-27 23:32:04

回答

0

不要使用在计算中的鼠标事件的位置。拇指偏移()。左侧加1/2它的宽度将会是中心