jQuery Color Animate (jQuery 颜色变换动画) 插件

转载地址: http://blog.netsh.org/posts/jquery-color-animate-plugin_619.netsh.html


弥补jQuery的不足

我们知道jQuery几乎是我们最常用的javascript库了,不过尽管他自己本身拥有大量的特效,但却仍然缺少一些动画效果。比如说,颜色、背景颜色的变换。弥补这一不足的方法给大家提供两个:

1、jQuery UI 库

jQuery是一款强大的jQuery插件性的特效库,通过jQuery UI可是实现下属功能:

Interactions

Complex behaviors like drag and drop, resizing, selection and sorting.

Widgets

Full-featured UI controls — each has a range of options and is fully themeable.

Utilities

Low-level utilities for building rich interactions, widgets, and effects.



你可以点击上面的链接查看在线demo。其中就包含color animate

color animate

附上jQuery UI API:

http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js

2、Edwin Martin提供的jQuery color animate插件

如果你只是需要颜色变换功能,也不必去花费时间装载一个和jQuery本身几乎一样大的插件。我就没有这么做。好在Edwin Martin为我们提供了单独的jQuery Color Animate插件,js本身很小,只有几行。实现效果可以有:

  • color
  • backgroundColor
  • borderColor
  • borderBottomColor
  • borderLeftColor
  • borderRightColor
  • borderTopColor
  • outlineColor

在线Demo演示:

DEMO
$('#demodiv').animate({color: '#E4D8B8'})  
$('#demodiv').animate({backgroundColor: '#400101'})  
$('#demodiv').animate({borderBottomColor: '#00346B'})  
$('#demodiv').animate({borderColor: '#F2E2CE'})  
$('#demodiv').animate({color: 'rgba(42, 47, 76, 0.1)'})  

是不是很酷呢?他的实现方法如下:

$(selector).animate({color:”#FFFFFF“},speed,callback_function);

其中color的值可以使hex值、RGB值;speed的单位是毫秒;callback_function是展示完之后要运行的函数。

下载

如果你需要,可以下载这两个js文件并调用就可以了,如果要使用就直接下载第一个,如果想研究的话就用第二个罢~:

谢谢收看。

PS: 在本站首页的硬又黑导航条(需要滚动条向下拖到能够到某个位置)、文章页面的分享导航条都有使用backgroundColor的渐变实现引人注意力的效果。



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值