jQuery + RGBA 颜色动画
IT技术
javascript
jquery
animation
2021-03-04 18:08:22
3个回答
使用 CSS3 动画(无 javascript)
您也可以使用 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
jQuery 现在也支持带有RGBA支持的彩色动画。这实际上是从一种颜色动画到另一种颜色。
$(selector).animate({
backgroundColor: 'rgba(0,255,0,0.4)'
});
呃,没关系。发现对 jquery 颜色插件的惊人修改。
使用jquery UI来处理,$(object).animate({color : 'rgba(0,0,0,.2)'},500)