原文地址:http://www.cnblogs.com/vaal-water/archive/2013/04/08/3008880.html 自己试过很好用 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) == '#'
科普下颜色代码 RGB格式:220,20,60(三个数字组成) HEX格式:#DC143C 代码如下 var rgb = '220,20,60'; alert(rgb2hex(rgb)); //将RGB转换成#HEX function rgb2hex(rgb) { var reg=/(\d{1,3}),(\d{1,3}),(\d{1,3})/; var arr=reg.exec(rgb); function hex(x) { return ("0" + parseInt(x).toSt
1.rgb转16进制 function to16 (a) {//RGB(204,204,024) //十六进制颜色值的正则表达式 var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/; var that = a; if (/^(rgb|RGB)/.test(that)) { var aColor = that.replace(/(?:\(|\)|rgb|RGB)*/g, "").split(","); var strHex =
hsv/hsb转rgb颜色 //h:[0,360],s:[0,100],v:[0,100] //return r:[0,256], g:[0,256],b:[0,256] function hsvtorgb(h, s, v) { s = s / 100; v = v / 100; var h1 = Math.floor(h / 60) % 6; var f = h / 60 - h1; var p = v * (1 - s); var q = v * (1 - f * s); var t = v
将RGB颜色值转换为16进制颜色值,主要是将 R.G.B 值分别转换为对应的十六进制值,填入 #RRGGBB 中. 推荐在线颜色转换工具:http://www.ecjson.com/rgbhex/ 例子: 输入:rgb(176,114,98) 输出:#B07262 代码如下: function colorRGBtoHex(color) { var rgb = color.split(','); var r = parseInt(rgb[0].split('(')[1]); var g = par
/*随机获取颜色*/ function getRandomColor() { var r = Math.floor(Math.random() * 256); var g = Math.floor(Math.random() * 256); var b = Math.floor(Math.random() * 256); return "rgb(" + r + ',' + g + ',' + b + ")"; //return '#' + Math.floor(Ma
var drawing=document.getElementById("drawing"); drawing.onclick= function () { var x, y, z; x=Math.floor(Math.random()*256); y=Math.floor(Math.random()*256); z=Math.floor(Math.random()*256); drawing.style.background='rgba('+x+','+y+','+z+','+1+'
HTML5的标签 video 支持的mp4编码为视频编码 H.264 音频AAC 参考网址 http://www.w3school.com.cn/html5/html_5_video.asp 视频格式 当前,video 元素支持三种视频格式: 格式 IE Firefox Opera Chrome Safari Ogg No 3.5+ 10.5+ 5.0+ No MPEG 4 9.0+ No No 5.0+ 3.0+ WebM No 4.0+ 10.6+ 6.0+ No Ogg = 带有 Theo
html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Con