# Color
# Random.color()
- Random.color()
随机生成一个有吸引力的颜色,格式为 '#RRGGBB'。
Random.color()
// => "#3538B2"
# Random.hex()
- Random.hex()
随机生成一个有吸引力的颜色,格式为 '#RRGGBB'。
Random.hex()
// => "#3538B2"
# Random.rgb()
- Random.rgb()
随机生成一个有吸引力的颜色,格式为 'rgb(r, g, b)'。
Random.rgb()
// => "rgb(242, 198, 121)"
# Random.rgba()
- Random.rgba()
随机生成一个有吸引力的颜色,格式为 'rgba(r, g, b, a)'。
Random.rgba()
// => "rgba(242, 198, 121, 0.13)"
# Random.hsl()
- Random.hsl()
随机生成一个有吸引力的颜色,格式为 'hsl(h, s, l)'。
Random.hsl()
// => "hsl(345, 82, 71)"
下面是一些随机生成的颜色:
<button id="genColor" type="button" class="btn btn-default">重新生成一批</button>
<div id="color100" class="color_100"></div>
<script>
$(function(){
$('#genColor').on('click', function(event){
var container = $('#color100').empty()
var color
for (var i = 0; i < 35; i++) {
color = Random.color()
$('<span class="circle"></span>')
.css('background-color', color)
.appendTo(container)
}
}).trigger('click')
})
</script>