Reputation: 1490
I am adding linear background dynamically to div. I have one color code in rgb format. How do you get end color code with slight different from colde which I have saved in backend using jquery. I am adding background like this
background: linear-gradient(-58deg, #0057a0, #00b8e1);
.
Basically I am adding linear background like this
style="background: linear-gradient(-58deg, '+Card.bgColor+', '+Card.bgColor+');"
.
Card.bgColor is a rgb value which is coming from backend. I wanted to just apply darker or lighter colorshade as a end color of gradient. Please help me.
Upvotes: 1
Views: 230
Reputation: 4400
If you are possible to use third party plugin then you can try something with this stuff TinyColor which provides functions to get lighten or darken color codes on what ever input you given.
tinycolor("#f00").lighten().toString(); // "#ff3333"
tinycolor("#f00").lighten(100).toString(); // "#ffffff"
Upvotes: 1