菜单鼠标悬停动画:在菜单链接上方显示突出显示
由于 HTML 限制,我有一个似乎无法解决的问题。
这是一个可以解释整个事情的捕获:
#
如您所见,我希望透明部分移动到鼠标悬停的菜单项上方。
但当我想到这一点时,我发现这不起作用,因为一旦透明部分到达鼠标下方,菜单项就会失去 :hover stat。
如果使用 actionscript3,则可以通过在我的透明部分上设置 .mouseEnabled 属性来轻松完成此操作,这样鼠标就不会考虑它。
你知道 html 是否可以实现类似的功能吗?您还有其他解决方案/途径可以遵循,以实现我想做的成功吗?
感谢您的帮助!
I have a problem that seem unsolvable, due to HTML limitations.
Here is a capture that may explain you the whole thing:
#
As you can see, I want a transparent part to move above the mouseovered menu item.
But as I am thinking that, I find out that this won't work cause the menu item will loose the :hover stat as soon as the transparent part will arrive below the mouse.
If where were with actionscript3, this would be easily done by setting the .mouseEnabled property on my transparent part, so that it isn't considered by the mouse.
Do you know if something similar is possible with html? Do you have other solutions/track to follow, to success what I wanted to do?
Thank you for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实现这种效果的关键是使用CSS属性z-index。例如,如果您的菜单结构如下所示:
技巧是使用 3 层,第一层是可以分配给 div 的菜单背景(棕色和白色),然后第二层是透明重叠,并且前面的那个是有链接的 LI。使用 css,它看起来像:
现在您只需使用 javascript 将透明重叠移动到当前悬停选项。
The key to accomplish this kind of effects is to use the CSS property z-index. For instance if your menu structure looks like this:
The trick is to work with 3 layers, the first is the background of the menu (brown and white) which could be assigned to the div, then the second layer is the transparent overlap, and the one in the front is the LI which has the link. With css it would look like:
Now you only need to move the transparent overlap to the current hovered option with javascript.