JSFiddle - React, Tailwind, and code Playground

by ariehg

HTML

<div id='res'></div>

CSS

#res{width:100px;height:100px}

JavaScript

Element.Properties.backgroundColor = {
        set : function(value){
            if (!Browser.ie) this.style.backgroundColor = value;
            var match = value.match(/rgba\(([0-9a-fA-F]{1,3}),([0-9a-fA-F]{1,3}),([0-9a-fA-F]{1,3}),(.*)+\)/);
            if (!match) this.style.backgroundColor = value;
            
            match.shift();
            match[3]*=100;
            for (var i = 0; i<4; i++){
                match[i] = match[i].toString(16);
                if (match[i].length==1) match[i] = "0" + match[i];
            }
            
            var alpha = match[3];
            match.pop();
            match.unshift(alpha);
            this.style.backgroundColor = "transparent";
            this.style.zoom = 1;            
            
            this.style.filter = "progid:DXImageTransform.Microsoft.gradient(startColorstr=#"+match.join()+",endColorstr=#"+match.join()+");"
        }
    }
$('res').setStyle('background-color','rgba(12,145,200,0.8)');