Is there an official CSS way to change the background color based on the child element in HEX?
For example:
render() {
return (
...
<span>
<h3 style={{ color: item.color }}>Item Color</h3>
</span>
...
}
I have experimented with mixBlendMode
(mix-blend-mode
) but it does the opposite of what I am trying to achieve.
If the text color of the h3
element is white and the background color of the span
element is also white, I want to change it to black. Similarly, if the text color is black, then the background should be white.
Is there a standardized way in CSS to accomplish this? Alternatively, is there a method using JavaScript to detect the color from a HEX value?
If the text color is white, then the background color should be black.
If the text color is black, then the background color should be white.
(And likewise for other colors)