2013-01-23 66 views
0

我有用户菜单,需要淡入和淡出鼠标和鼠标从图标。我的问题是,用户也应该能够悬停在菜单上(或在这种情况下,img),而不是菜单淡出,以便他们可以点击链接或图像内。这是我的代码和jsfiddle。 http://jsfiddle.net/anschwem/7mrM2/用户菜单淡入和淡出

<style> 
div.notif 
{ 
    display:none; 
    position:absolute; 
    border:solid 1px black; 
    padding:8px; 
    background-color:white; 
} 
a.notif:hover + div.notif 
{ 
    display:block; 

} 
div.notif:hover 
{ 
    display:block; 

} 
</style> 
<script type='text/javascript'>//NOT WORKING 
$(window).load(function(){ 
$(document).ready(function() 
{  
    $(".notif").hover(
     function() { 
     $('.notif').fadeIn('slow'); 
     }, 
     function() { 
     $('.notif').fadeOut('slow'); 
     } 
    ); 
}); 
});//]]> 
</script>//NOT WORKING 
</head> 
<body> 
<a class="notif" href="notifications.html" style="text-decoration:none;"><img src="images/bubble.png" style="position:relative; top:20px;"/></a> 
    <div class="notif" style="z-index:999999; "> 
<a href="notifications.html"><img src="images/notif.png"/></a> 
</body> 
+0

链接从网站骗取钱财的图像。处理破碎的图像并不容易......另外,在jsFiddle中,您必须将jQuery设置为框架。 [更新的小提琴](http://jsfiddle.net/DJDavid98/7mrM2/1/) – SeinopSys

+0

你不能悬停在一些不可撼动的东西上。 'fadeOut'以'display:none'结尾!从这个角度来看,你在徘徊什么,以便它“褪色”?没有! – kidwon

+0

我可以带走淡入淡出的代码,我只是认为这会有所帮助。我之前使用过它,只是当您将鼠标悬停在(新淡入)菜单上时,它会消失,因为您将鼠标悬停在图标上以专注于菜单。 – triplethreat77

回答

0

这会帮助你。见JSFiddle demo

HTML

<div class='parent'> 
    <a class="notif" href="notifications.html" style="text-decoration:none;"><img src="http://upload.wikimedia.org/wikipedia/commons/a/ac/Approve_icon.svg" height="30" width="30"/></a> 

    <div class="notif" style="z-index:999999; "> 
     <a href="notifications.html"><img src="http://doinghistoryproject.tripod.com/sitebuildercontent/sitebuilderpictures/failure-message.gif" height="80" width="80"/></a> 
    </div> 
</div> 

JS

$(document).ready(function() { 
    $(".parent").hover(
    function() { 
     $(this).find('div.notif').stop().fadeIn('slow'); 
    }, 
    function() { 
     $(this).find('div.notif').stop().fadeOut('slow'); 
    }); 
}); 
+0

狼!我们再见面。这很好,只有一个悬停菜单。如果我想让我们说3呢?如果您使用不同的ID添加多个ID,他们会召唤对方。奇怪。 – triplethreat77

+0

你可以更新复制该案件的小提琴吗? – Wolf

+0

嗯,我复制了你有的东西,你可以看到它们很糟糕.http://jsfiddle.net/anschwem/7mrM2/12/ – triplethreat77