I am facing a challenge where I have two div
elements with different transparent, colored backgrounds that overlap each other.
My goal is to find a way to customize the color in the area where these elements overlap.
For instance, if I blend red and blue with an opacity of 0.5, I would like the overlapping region to appear black. Is this achievable? Such a solution would greatly simplify the implementation process.
To provide a clearer illustration, consider the following example:
.wrapper{
width: 200px;
height: 500px;
background-color: #fff;
position: relative;
}
.box{
width: 100%;
position: absolute;
}
.box-1{
top: 0px;
height: 250px;
background-color: rgba(181, 226, 163, 0.5);
}
.box-2{
background-color: rgba(183, 222, 241, 0.5);
top: 200px;
height: 300px;
}
<div class="wrapper">
<div class="box box-1">
</div>
<div class="box box-2">
</div>
</div>
UPDATE:
The specific height of the overlapped area is unknown, so simply adding a rigid element with a fixed height such as 50px
is not a viable approach. The core question revolves around finding a method to custom mix colors in this scenario.