【发布时间】:2012-01-21 15:28:47
【问题描述】:
我在一个页面上有一系列照片,当你将鼠标悬停在它们上面时,白色的效果会淡入,并且标题和说明会出现在上面。
我遇到的问题是,如果我将鼠标悬停在文本区域上,则白色效果会再次淡出。这是一个奇怪的闪烁问题。
我需要它工作,以便无论您将鼠标悬停在图像上的哪个位置,它始终保持着色,并且无论何时关闭它都会恢复为普通图像。
我的代码如下。
$('div.project-image a img').mouseover(function() {
$('div.hover').css('filter', 'alpha(opacity=70)');
$('div.hover', $(this).parent().parent()).fadeIn(500);
});
$('div.hover').mouseout(function() {
$('div.hover').css('filter', 'alpha(opacity=70)');
$('div.hover', $(this).parent().parent()).fadeOut(500);
});
$('div.hover').bind('click', function(e) {
window.location = $(this).parent().children('a').attr('href');
});
使用的 CSS 样式有:
#content div.project-image (styles the image area)
#content div.hover (displays the white tinted image)
#content div.hover h1 (styles the title)
#content div.hover p (styles the description)
【问题讨论】:
-
jsfiddle.net 上传足够的代码来复制问题
-
我确实尝试过这样做,但我无法让它工作。代码分布在 wordpress 主题的不同部分。
标签: jquery hover nested flicker