Adapt text color depending on the background color
-
Hello,
I would like to know if there is any way to change a text color depending on the background color.
I mean by that, if my background is black I want the text to be white if is white I want the text to be black.Here is an example where it invert the color. But just a switch to the most readable color would be enough. :
Here a working example for HTML, CSS and JS example : https://codepen.io/jpod/pen/Aytcr
-
Hello,
I would like to know if there is any way to change a text color depending on the background color.
I mean by that, if my background is black I want the text to be white if is white I want the text to be black.Here is an example where it invert the color. But just a switch to the most readable color would be enough. :
Here a working example for HTML, CSS and JS example : https://codepen.io/jpod/pen/Aytcr
@DavidM29
see this approach.
You will have to pass the background color yourself though.
Also it won't be easily possible to have the text color changed in mid-text. -
@DavidM29
see this approach.
You will have to pass the background color yourself though.
Also it won't be easily possible to have the text color changed in mid-text.Thank you for those elements ! It will help a bit event if I believe it will not be as I expected it to be.