我正在尝试使用淡入淡出jquery插件。昨天在这里的其他人的帮助下,我让它几乎完美地工作了。但是,当我第一次将鼠标悬停在div上时,效果上的淡入淡出效果似乎不起作用。它在第二次和随后的悬停之后工作。而且淡出效果似乎一点也不起作用。
注意:当你将鼠标悬停在步骤1上时,不会发生任何事情,但当你将鼠标悬停在其他步骤上时,颜色块应该会淡入/淡出。我更多的是一个设计师,所以我不确定为什么动画没有在第一次悬停时发生。这是编写JS代码的正确方式吗?
$(document).ready(function () {
$("div.secure").hover(
function() {
$("div.secure-hover").stop(true, true, true).fadeIn('slow');
},
function() {
$("div.secure-hover").stop(true, true, true).fadeOut('slow');
}
);
$("div.cash").hover(
function() {
$("div.steps-hover.cash-hover").stop(true, true, true).fadeIn('slow');
},
function() {
$("div.steps-hover.cash-hover").stop(true, true, true).fadeOut('slow');
}
);
$("div.credit").hover(
function() {
$("div.credit-hover").stop(true, true, true).fadeIn('slow');
},
function() {
$("div.credit-hover").stop(true, true, true).fadeOut('slow');
}
);
});谢谢你的帮助。
发布于 2013-07-13 01:51:56
在你的css上,你有像这样的"div.cash:hover you . -hover -hover“
div.default, div.cash:hover div.cash-hover, div.secure:hover div.secure-hover, div.credit:hover div.credit-hover{
margin: 0;
padding: 0;
width: 960px;
text-align: center;
height: 180px;
position: absolute;
top: 234px;
display: block;
left: 0;
z-index: 3;
right: 0px;
cursor: auto;
} 它仅当您将鼠标悬停在元素div.cash上时才设置属性width,height,...etc,如果您像这样更改它的话
div.default, div.cash-hover,div.secure-hover, div.credit-hover{
margin: 0;
padding: 0;
width: 960px;
text-align: center;
height: 180px;
position: absolute;
top: 234px;
display: block;
left: 0;
z-index: 3;
right: 0px;
cursor: auto;
}
//set all -hover to display none
div.cash-hover, div.secure-hover, div.credit-hover {
display: none;
}您从一开始就设置了div.ash-hover的属性,这样$("div.cash").hover就可以为不透明http://jsfiddle.net/c6gRp/6/设置动画效果
发布于 2013-07-13 00:40:33
您没有为div.online-hover指定任何内容。
$("div.online").hover(
function () {
$("div.online-hover").stop(true, true, true).fadeIn('slow');
},
function () {
$("div.online-hover").stop(true, true, true).fadeOut('slow');
});https://stackoverflow.com/questions/17619465
复制相似问题