Javascript jQuery + RGBA 颜色动画
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3242368/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jQuery + RGBA color animations
提问by Matrym
采纳答案by Matrym
Uh, nevermind. Found an amazing modification to the jquery color plugin.
呃,没关系。发现对 jquery 颜色插件的惊人修改。
回答by Selvakumar Arumugam
Using CSS3 animation(no javascript)
使用 CSS3 动画(无 javascript)
You can also achieve the same effect using CSS3 animation. See below,
您也可以使用 CSS3 动画实现相同的效果。见下文,
Step 1:Create a keyframe for your animation
第 1 步:为动画创建关键帧
@keyframes color_up {
from {
background-color: rgba(0,0,0,0.2);
}
to {
background-color: rgba(0,255,0,0.4);
}
}
Step 2:Use the animation rules.
第 2 步:使用动画规则。
animation-name: color_up;
animation-duration: 2s;
animation-iteration-count: infinite;
animation-direction: alternate;
animation-timing-function: ease-in-out;
DEMO:http://jsfiddle.net/2Dbrj/3/
演示:http : //jsfiddle.net/2Dbrj/3/
Using jQuery
使用 jQuery
jQuery now supports coloranimationwith RGBAsupport as well. This actually animates from one color to other.
jQuery 现在也支持带有RGBA支持的彩色动画。这实际上是从一种颜色动画到另一种颜色。
$(selector).animate({
backgroundColor: 'rgba(0,255,0,0.4)'
});

