I need a CSS styling that makes the text color white when the background is red and a black text color when the background is white.

My red background has the following color: #d6002e

I added this CSS to my text:

mix-blend-mode: difference; color: #29FBFF; // Inverted color of my red 

Now it looks like this :

enter image description here

My text gets the inverted color of the background, which is not exactly what I want.

1

1 Answer

I feel this should solve the problem

.my-red-bg { background: #d6002e; color: white } .my-black-bg { background: black; color: white } 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy