Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

color input with transparency

Tags:

html

css

Is it possible to select transparent colors using built in

<input type="color">

I haven't found a slider that does that. Is there some option additional I need to check?

like image 604
sanjihan Avatar asked Sep 30 '17 13:09

sanjihan


People also ask

How do I make background color transparent?

To set the opacity of a background, image, text, or other element, you can use the CSS opacity property. Values for this property range from 0 to 1. If you set the property to 0, the styled element will be completely transparent (ie. invisible).

How do you make a transparent input box in CSS?

Setting Transparent Boxes You can set the CSS transparent background for boxes by adding the opacity property to multiple <div> elements. Tip: you should notice that texts inside boxes take the opacity of the CSS transparent background. The RGBA function allows you to keep the text opacity.


1 Answers

AFAIK there's no option for transparent color picking using <input type="color">, but what you could do is have another input for the alpha, and set the opacity of the color input like this:

function updateColorAlpha (alpha) {
    document.getElementById('color').style.opacity = alpha;
}
<input type="color" id="color">
<input type="range" id="alpha" onchange="updateColorAlpha(this.value);" min="0" max="1" step="0.1" value="1">
like image 169
Ethan Avatar answered Sep 30 '22 08:09

Ethan