简体   繁体   English

我如何拥有Google+风格的悬浮卡?

[英]How can I have the Google+ style hovercard?

I really like the Google+ style hovercard. 我非常喜欢Google+风格的悬浮卡。 When you hover over a profile picture, it pops up a little box, similar to the "established users" hovercards here on Stack Overflow. 当您将鼠标悬停在个人资料图片上时,会弹出一个小框,类似于Stack Overflow上的“已建立的用户”hovercards。

Google+悬停卡

I know how to do the CSS, but the JavaScript is what I need help with. 我知道如何做CSS,但JavaScript是我需要帮助的。

I have a code here that is somewhat like it: http://jsfiddle.net/NathanJohnson/AhVQN/ But, it doesn't work that good. 我在这里有一个类似的代码: http//jsfiddle.net/NathanJohnson/AhVQN/但是,它没有那么好用。 The mouse offset does not work correctly. 鼠标偏移无法正常工作。

Could someone help me with getting this working properly? 有人可以帮助我正常工作吗? Thanks in advance. 提前致谢。

You can change the mouse offset in this section: 您可以在此部分中更改鼠标偏移:

  var pos = {
        // or you could position it relative to the mouse
        top: (e.clientY + 2) + 'px',
        left: (e.clientX + 2) + 'px'
    };

Change the e.clientY + 2 to e.clientY + 1 and the hovercard will be closer to the cursor. e.clientY + 2更改为e.clientY + 1 ,hovercard将更接近光标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM