问题描述
|
我需要从透明到彩色进行动画处理,但是当我得到白色闪光时。我认为这是因为没有可用于设置动画的基色。我该如何解决?
$(\'#nav a\').hover(function() {
$(this).animate({
\'background-color\' : $(this).attr(\'data-background\'),\'color\' : $(this).attr(\'data-rollover\')
},900);
});
<a style=\"color:#ffff00; \" data-background=\"#000066\" data-color=\"#ffff00\" data-rollover=\"#000000\" href=\"index.PHP?p=1\" ><span >Home</span></a>
解决方法
设置
opacity
而不是background-color
属性的动画。
, 亚历克斯是对的。你已经用opacity
做到了。您可以尝试以下方法:
$(\'#nav a\').hover(function() {
$(this).animate({
\'opacity\': 0
},1,function() {
$(this).css({
\'background-color\': $(this).attr(\'data-rollover\'),\'color\': $(this).attr(\'data-color\')
}).animate({
\'opacity\': 1
},900);
});
});