Problem:
A child element and its container both have a bg color with transparency. If the child element is inside the container, the color of the child element will be calculated based on the parent's. What should I do to keep transparency of both while making the child bg color exactly the same as what I spcify.
For example:
I have a fullscreen background image.
And a div
with children elements inside.
<div class="container">
<input class="mask-moderate__input" />
<button class="mask-moderate__button"></button>
</div>
Each of the styles defines an rgba background.
This may somehow picture the situation. The "color 2" on the left is what I want, because I didn't put it in a container and its color rgba(90, 90, 90, 0.35)
is calculated directly based on the background. But if I write elements in the div (as in the header bar), the bg color will be calculated based on the div's bg color rgba(55, 55, 55, 0.35)
, which is not what I want.
Possible solution:
Perform linear dodge. Just add the rgb delta based on the div's bg color and keep the alpha unchanged, so that (55, 55, 55, 0.35) + (35, 35, 35) = (90, 90, 90, 0.35) <- the same as "color 2" on the left.
Fill a
div
with but keep out a certain area. (Don't fill areas where elements are right above)Script ways.
Note:
I'm working on an Angular 6 project. Any solution out of scope of vanilla JS is also welcome.
Thank you!