如何在$(this)上使用Jquery方法.animate()进行以下操作:
background: -webkit-gradient(linear, left top, left bottom, from(#2d2d2d), to(#373737))
我尝试使用:
$(this).css("background", "-webkit-gradient(linear, left top, left bottom, from(#d70000), to(#679938))");
哪个工作正常,但我想定义过渡所需的时间
@-webkit-keyframes changeBG {
0% {
background: -webkit-gradient(linear, left top, left bottom, from(#2d2d2d), to(#373737));
}
50% {
background: -webkit-gradient(linear, left top, left bottom, from(#666), to(#737373));
}
100% {
background: -webkit-gradient(linear, left top, left bottom, from(#2d2d2d), to(#373737));
}
我使用-webkit-keyframes和类更改了200ms的时间来解决了这个问题。如果有人有想法,如何直接将-webkit-keyframes包含在Jquery中,而无需转移类,请写下您的答案。另外,对于.animate()为什么不起作用,我一无所知。如果有人能回答我,我将很感激
$(this).addClass('akt');
setTimeout(function () { $(this).removeClass('akt'); }, 200);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句