【发布时间】:2011-07-25 22:24:59
【问题描述】:
我正在使用此脚本在悬停时淡入另一个图标。
我还想在顶部图像完成淡入后隐藏上一个图像。
我遇到的问题是,当您将鼠标悬停在它上面时,它似乎在消失之前闪烁。我需要停止闪烁!
下面是我的 HTML 和 jQuery 代码。我试图让这段代码有点通用。
.link-container {
position: relative;
cursor: pointer;
float: left;
}
.title-hover {
background-position: 0 -106px;
width: 320px;
height: 33px;
margin: -32px 0 0 56px;
display: none;
z-index: 2;
}
.title {
background-position: 0 -63px;
width: 320px;
height: 33px;
margin: -32px 0 0 56px;
}
<div class="link-container">
<div class="main-tile hover-init title"></div>
<div class="main-tile title-hover"></div>
</div>
$(function () {
$(".link-container").hover(function () {
$(".hover-init", this).next().stop(true, true).fadeIn(400);
$(".hover-init", this).hide();
}, function () {
$(".hover-init", this).next().stop(true, true).fadeOut(400);
$(".hover-init", this).show();
});
});
【问题讨论】:
-
你没有发布 HTML,只是 CSS。
-
jquery 是旧的,这里是最新版本以及 html。我想淡入 .next 然后隐藏悬停初始化。然后到相反的淡出。您建议的方法有效,但它不会隐藏悬停初始化它只是将 .next 淡化在另一个之上,这看起来不太好 =/
-
你在回复我的回答对吗?
-
是的,我正在响应您的建议
标签: jquery hover fadein fadeout