使用 Javascript 在 MouseOver 上的其他元素之上显示 Html 元素
在 Espn 的此页面上。 com,如果您转到右上角并将鼠标悬停在“myESPN”上,则会出现一个内联弹出窗口(如果可以称为该窗口)(以一种看起来连接到初始按钮的方式)并允许用户登录该网站。
在 html 中,看起来有一个隐藏的 div,当鼠标移到某个元素上时,它会变得可见并被推到前面,并且只要鼠标停留在调用元素或新显示的元素上,它就会保持在视图中本身。
我想做类似的事情。 然而,在对 Firebug 进行了一些探索之后,我无法准确地确定它是如何完成的。 我认为它涉及 javascript,也可能涉及 jquery - 任何人都可以帮助解决实施细节吗?
On this page in Espn.com, if you go to the upper right corner and hover over "myESPN", an inline popup window (if that is what it can be called) appears (in such a way that it looks connected to the initial button) and allows the user to log in to the site.
In the html it looks like there is a hidden div that is made visible and is pushed to the front when the mouse goes over a certain element, and stays in view as long as the mouse remains on the calling element, or the newly shown element itself.
I am looking to do something similar. However, after poking around a bit with Firebug, I am unable to identify exactly how it is done. I assume that it involved javascript, and probably jquery as well - can anyone help with the specifics on implementation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要的是一个绝对定位的 div 元素,您可以按照您希望的显示方式定位它。 然后用 style="display: none;" 隐藏它,并在鼠标悬停在右侧元素上时显示它。 使用 jQuery 则为:
编辑:
隐藏它:
或类似的东西......
What you need is an absolutely-positioned div-element, which you position the way you want it to appear. Then you hide it with style="display: none;", and on mouseover of the right element, you show it. With jQuery that'd be:
Edit:
To hide it:
or something similar...
以下视觉事件书签是一个可以帮助您的好工具。 它允许您查看与页面上的元素相关的所有事件。
当在页面上运行时,会显示覆盖层,并且小图标会放置在具有脚本事件的元素旁边。 您可以将鼠标悬停在图标上以查看实际的 js。 请注意,如果开发人员已经足够好来缩小 js,那么您看到的脚本将没有太大意义。
(来源:gyazo.com)
A good tool to help you is the following Visual Event bookmarklet. It allows you to see all the events that are tied to elements on the page.
When run on a page an overlay is shown and little icons are placed next to the elements that have script events. You can hover the icons to see the actual js. Be warned if the developers have been good enough to minify the js then the script you see will not make too much sense.
(source: gyazo.com)