I am building a color picker that uses CSS gradients instead on images. I have a CSS gradient that works for HSB color selection but I am unable to create a CSS gradient for HSB color selection. You can see the original gradient at:
http://jsfiddle.net/qVsFN/
Gradient 1 should look like gradient 2. Is it possible to do this with only css? I tryed several things including radial gradients with no luck.
Here is the css and markup I am using:
#red_grad {
background: -moz-linear-gradient(0deg, rgba(255, 255, 255, 1), rgba(255, 0, 0, 1)) repeat scroll 0 0 transparent;
background: -webkit-gradient(linear, left center, right center, from(rgba(255, 255, 255, 1)), to(rgba(255, 0, 0, 1)));
height: 262px;
width: 262px;
}
#black_grad {
background: -moz-linear-gradient(90deg, rgba(0, 0, 0, 1), transparent) repeat scroll 0 0 transparent;
background: -webkit-gradient(linear, center bottom, center top, from(rgba(0, 0, 0, 1)), to(transparent)) repeat scroll 0 0 transparent;
height: 262px;
width: 262px;
}
<div id="red_grad">
<div id="black_grad">
</div>
</div>
You can see it live at http://jsfiddle.net/qVsFN/
The HSL Saturation-Lightness plane can be made with 2 linear gradients:
Here’s a fiddle with it: http://jsfiddle.net/leaverou/qVsFN/3/
Notes:
And what about changing the hue? Just substitute
redfor the fully saturated version of the new color (Hue = whatever, sat = 100, lightness = 50) — and there’s your color picker!