菜单鼠标悬停动画:在菜单链接上方显示突出显示

发布于 2024-10-10 19:41:11 字数 381 浏览 2 评论 0原文

由于 HTML 限制,我有一个似乎无法解决的问题。

这是一个可以解释整个事情的捕获: imgage

#

如您所见,我希望透明部分移动到鼠标悬停的菜单项上方。

但当我想到这一点时,我发现这不起作用,因为一旦透明部分到达鼠标下方,菜单项就会失去 :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:
imgage

#

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

山有枢 2024-10-17 19:41:11

实现这种效果的关键是使用CSS属性z-index。例如,如果您的菜单结构如下所示:

<div id="menu">
  <ul>
    <li>
      <a href="#">Master/PHD Education</a>
      <span>Introduction, Master & Doctorans</span>
    </li>
  </ul>
  <div id="transparent_overlap"></div>
</div>

技巧是使用 3 层,第一层是可以分配给 div 的菜单背景(棕色和白色),然后第二层是透明重叠,并且前面的那个是有链接的 LI。使用 css,它看起来像:

#menu{
   background:..
}

#transparent_overlap{
   background:..transparent effect..
}

li{
   position:relative;
   z-index:3;
}

现在您只需使用 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:

<div id="menu">
  <ul>
    <li>
      <a href="#">Master/PHD Education</a>
      <span>Introduction, Master & Doctorans</span>
    </li>
  </ul>
  <div id="transparent_overlap"></div>
</div>

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:

#menu{
   background:..
}

#transparent_overlap{
   background:..transparent effect..
}

li{
   position:relative;
   z-index:3;
}

Now you only need to move the transparent overlap to the current hovered option with javascript.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文