比较笨的随机颜色
饱和度较低的几种随机颜色,JavaScript算法 <!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="Content-Type" content="text/html; charset=utf-8" /> <title>colors</title> <style type="text/css"> .div {width:100px; height:100px; float:left;} </style> </head> <body> <div class="div"></div> <div class="div"></div> <div class="div"></div> <div class="div"></div> <div class="div"></div> <div class="div"></div> <script type="text/javascript"> window.onload=function(){ var obj=document.getElementsByClassName('div'); for(var i=0;i<obj.length;i++){ obj[i].style.backgroundColor=hsl2color([radomFuc(360), 100, 70]) } } function radomFuc($value) { //取随机数 return parseInt($value * Math.random()); } function hsl2color(hsl) { //HSL颜色算法 if (hsl[0] > 360 || hsl[0] < 0 || hsl[1] > 100 || hsl[1] < 0 || hsl[2] > 100 || hsl[2] < 0) return "#000000"; var...
Read More