您也可以使用CSS3动画实现同样的效果。请参见下面的内容:
步骤1:为您的动画创建一个关键帧。
@keyframes color_up {
from {
background-color: rgba(0,0,0,0.2);
}
to {
background-color: rgba(0,255,0,0.4);
}
}
步骤2:使用动画规则。
animation-name: color_up;
animation-duration: 2s;
animation-iteration-count: infinite;
animation-direction: alternate;
animation-timing-function: ease-in-out;
演示: http://jsfiddle.net/2Dbrj/3/
jQuery现在支持颜色动画,同时也支持RGBA。这实际上是从一种颜色到另一种颜色的动画。
$(selector).animate({
backgroundColor: 'rgba(0,255,0,0.4)'
});
哦,没关系了。找到了一个很棒的jquery color插件修改版。