我有一个菜单,悬停时我会淡入一个框。在这个框后面我有一个小图标,我想将它移到框前面,以便您可以在悬停时看到它。
这是我的菜单> Navigation
我尝试了 jQuery(this).find(".flyer").css("z-index", 10000);
但它仍然落后。
我该如何解决这个问题?
问候麦克斯
最佳答案
z-index
仅适用于定位元素,因此您需要为 .flyer
提供 position
,如下所示:
.flyer{
margin: -75px 0 0 0;
width:53px;
height:74px;
position: relative;
}
Here's your example/fiddle edited to work ,我们只是在悬停时调用它:
$(this).find(".flyer").css("z-index", 10000);
鼠标悬停时:
$(this).find(".flyer").css("z-index", "auto");
关于javascript - jQuery z-index 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3423391/