$(".block li").hover(
function(){
$(this).animate({backgroundColor: "#000"});
},
function(){
$(this).animate({backgroundColor: "#fff"});
}
);
需要改变#fff
到没有颜色。动画应该发生于#000
to transparent
.
有什么解决办法吗?
你可以使用rgba(...)
(请参阅此处的浏览器支持).
var elem = $('#foo')[0];
$({
r: 0,
g: 0,
b: 0,
a: 1
}).animate({
a: 0
}, {
step: function() {
elem.style.backgroundColor =
'rgba(' +
~~this.r + ',' + ~~this.g + ',' + ~~this.b + ',' +
~~(this.a*100)/100 +
')';
},
duration: 1000
});
~~
是底值,否则你最终会得到类似的东西rgba(0.1029302...
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)