简体   繁体   English

jQuery在菜单悬停上添加透明覆盖

[英]jQuery Add Transparent Overlay on Menu Hover

I am trying to recreate the effect found here 我正在尝试重新创建在这里找到的效果

When hovering over the mega menu li > a element the background / opacity changes over the page wrapper I am assuming but I am not sure the best way to achieve this with jQuery. 当我将鼠标悬停在大型菜单li>元素上时,背景/不透明度会随着页面包装器的变化而变化,但是我不确定用jQuery实现此效果的最佳方法。

Should I use css to change the background or opacity or jQuery itself to try to recreate this effect. 我应该使用css更改背景或不透明度还是使用jQuery本身来尝试重新创建此效果。

Any pointers would be much appreciated. 任何指针将不胜感激。

You don't need Javascript to accomplish that :) 您不需要Java语言即可完成此操作:)

Use position: fixed on the inner child of your li like this: 使用position: fixed在您的li内子上,如下所示:

<li>
   <a href="#"></a>
   <div class="overlay"></div>
</li>

and.. 和..

.overlay {
   display: none;
   position: fixed;
   top: 0;
   left: 0;
   right: 0;
   bottom: 0;
}

li:hover .overlay {
   display: block;
}

Example: http://jsfiddle.net/serb4q2v/ 示例: http //jsfiddle.net/serb4q2v/

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

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