抽取图片的主颜色并作为其父元素的背景色:jquery.adaptive-backgrounds.js

jopen 10年前

抽取图片的主颜色并作为其父元素的背景色:jquery.adaptive-backgrounds.js
jquery.adaptive-backgrounds.js是一个简单的jQuery插件用来提取图像的主色,并把它并作为其父元素的背景色。

用法,只要简单的引入 jQuery 和 script 在你的页面中,然后运行以下脚本:

$(document).ready(function(){    $.adaptiveBackground.run()  });

这个脚本会查找包含 data-adaptive-background属性的图片。

<img src="/image.jpg" data-adaptive-background='1'> 
12071245_w4ss.jpg.gif

项目主页:http://www.open-open.com/lib/view/home/1407811000723