我有一个带有CSS3渐变的按钮(锚点)。
我希望当用户悬停在按钮上时,能够将渐变动画/淡入到一种颜色。
问题是我找不到如何实现这一点- 因为jQuery UI对颜色的动画仅适用于常规颜色,而不适用于渐变。
有什么想法吗?
谢谢!
我为支持此功能的浏览器编写了一个jQuery插件,用于动画化Css3渐变。
您可以在这里找到它。
它使用我编写的Gradient cssHook来规范化CSS3渐变,使其更易于使用。
您可以像这样使用它:
$("#elem").animateGradient('linear-gradient(red, blue)', 1000);
$.queue
和$.dequeue/next()
,所以你也可以添加其他动画。$('#divId').backgroundor();
即可工作,而且还有很多选项可供选择。请看一下:// the values here are the default values
options = {
opacityval : 0; // int, only 1 or 0 are accepted now (can be boolean too)
intervaltime : 100; // int, interval time value
values : [0,51,75]; // array of int, default percentage values for the linear gradient colors
colors : ['#499bea','#207ce5','#1679e3']; // array of string (hex values), default colors for the linear gradient
color : '#000000'; // string (hex value), default color for opacity animation
animspeed : 'linear'; // string, default animation curve
animdegree : '90deg'; // string, default linear-gradient degree
}