blend

一个在jQuery 基础的CSS 背景动画效果插件。

默认的CSS换转,没有JavaScript

Home Blog Demo About Services Contact

Blend 默认效果: $(selector).blend();

Home Blog Demo About Services Contact

Blend+Pulse: $(selector).blend({pulse:true});

Home Blog Demo About Services Contact

Blend+Reverse: $(selector).blend({reverse:true});

Home Blog Demo About Services Contact

测试环境: Firefox 3, Safari 3 & 4, Opera 9, Chrome, Internet Explorer 6, 7, 8.
不兼容Firefox2,是由于 background-position 属性 bug.

Released under the MIT License.

操作指南

除了你常用的CSS ‘:hover’ 样式, 一个‘hover’ 样式必须要添加到目标元素。这是必须的,因为 JavaScript 还没有办法能探测到 CSS 的 ‘:hover’ 样式,对于这个插件是必须的。

正常的 CSS :hover style: #navHome:hover{background:#f00}

和 hover class 同样的 CSS : #navHome:hover, #navHome.hover{background:#f00}

blend() 函数带有一个 key/value 对象和一个 callback 选项

格式: $('selector').blend({key:value, key:value});

这个页面的上面有很多示例。

KeyDefaultDescription
speed500 设置 blend 效果的速度,单位毫秒
opacity1 在内容没有加载之前,初始化高度
targetfalseThis takes in a jQuery selector that can be used to change the target of the blend effect. Example:
$("#downloadLink").blend({target:"#downloadButton"});
pulsefalseIf true, pulse will cause the blend animation to loop.
activefalseIf true, the blend effect will run as if the visitor is mousing-over it.
topfalseIf true, the hover state will appear on top of the content inside of the target element.
reversefalseIf true, flips the default and hover CSS backgrounds.

局限性 & IE6 兼容性

Blend 或许和你某些CSS不兼容, 他需要元素为盒装或者是被定义了“display:block”的内联元素。但是在使用内联元素的时候还是要看实际情况而论。

IE6 does not support class chaining. Since Blend adds a class of 'hover', this may result in an incorrect background for CSS-sprites if the element had a pre-existing class that the background properties are affected by. Example: '.home.hover' may not work in IE6 if CSS sprites are in use, '#home.hover' would work fine however.