Answer the question
In order to leave comments, you need to log in
How to find out the true background color of an element? Considering all parents, who can have semi-transparent background colors?
Actually, you need to calculate the contrast level of the font color and background color.
The background color can be semi-transparent, and consist of many overlays of semi-transparent layers behind it.
It is necessary to somehow calculate the real, real background color, taking into account all the parents from the desired element.
For example, such a structure (scss):
body {
background-color: lightgreen;
div.cont1 {
background-color: rgba(192, 0, 0, 0.5);
div.cont2 {
background-color: rgba(0, 128, 128, 0.333);
span.text {
color: red;
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Found the solution: https://jsfiddle.net/5ptdk7sv/
Thanks everyone, the answers helped me point my search in the right direction :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question