So in the code below, I have a --pop
colour, and a --bg
background color. I wish to calculate a hover color from the two as follows:
Mix --pop
with the inverse with --bg
.
e.g. if the background is black, I wish to mix --pop
with white.
--bg
could be any color.
--pop: #123456;
--bg: black;
--hover: color-mix(in srgb, var(--pop) 30%, ???inverse of --bg here???)
2
Answers
If the JavaScript solution is okay you can try something like:
Then
Here is a CSS only solution from the future using relative color syntax
It has no support right now but soon you will be able to test it on Chrome