没有图像 !只是 JS 和 CSS 文件
非常直观类似 Photoshop 的界面
光明和黑暗很容易自定义 CSS3 外观
28 KB 总由浏览器加载看起来不错甚至在 IE7及工程非常容易实现
截图

下载该插件和 colpick.js 和 colpick.css 添加到您的文档的头:
<script src="js/colpick.js" type="text/javascript"></script> <link rel="stylesheet" href="css/colpick.css" type="text/css"/>
现在你可能会在任何 jQuery 对象来创建一个颜色选取器上调用colpick方法。默认情况下您获取下拉列表颜色选择器:
html
<button id="picker">Show Color Picker</button>
js
$('#picker').colpick();传递给 colpick 函数作为对象的几个选项允许您自定义颜色选择器。例如,传递flat:true使颜色选取器总是可见的如下面的示例。
html
<div id="picker"></div>
JS
$('#picker').colpick({
flat:true,
layout:'hex',
submit:0
});
动态设置初始化的颜色:
//rgb转16进制
function zero_fill_hex(num, digits) {
var s = num.toString(16);
while (s.length < digits)
s = "0" + s;
return s;
}
function rgb2hex(rgb) {
if (rgb.charAt(0) == '#')
return rgb;
var ds = rgb.split(/\D+/);
var decimal = Number(ds[1]) * 65536 + Number(ds[2]) * 256 + Number(ds[3]);
return "" + zero_fill_hex(decimal, 6);
}
$('#picker').colpick({
layout:'rgbhex',
onBeforeShow:function(a){
$(this).colpickSetColor(rgb2hex($(this).css("background-color")));
},
onSubmit:function(hsb,hex,rgb,el){//ok之后的确认事件
console.log('#'+hex);
$(el).css('background-color', '#'+hex);
$(el).colpickHide();
}
});
回复
defaults = {
elem:"body"
},
if (options.flat) {
cal.appendTo(this).show();
cal.css({
position: "relative",
display: "block"
})
} else {
cal.appendTo($(options.elem));
$(this).on(options.showEvent, show);
cal.css({
position: "absolute",
"z-index":"999999999"
})
}增加一个默认body,然后下面的元素绑定更改为元素绑定即可