I have a setup that uses nested, absolute-positioned divs, and I need mix-blend-mode
to blend the elements of a div with all of elements that have a lower z-index than that div.
The catch is that each div must have its own independent z-index (this cannot be changed for accessibility reasons).
This is easier to explain with an example:
#layer-1 {
width: 700px;
height: 700px;
position: absolute;
background-color: maroon;
z-index: 1;
}
#layer-2 {
position: absolute;
height: 100px;
width: 200px;
z-index: 2;
}
#layer-3 {
position: absolute;
z-index: 3;
mix-blend-mode: darken;
}
#layer-3 img {
width: 300px;
}
<div id="layer-1"></div>
<div id="layer-2">
<div id="layer-3">
<img src="https://i.picsum.photos/id/100/2500/1656.jpg" />
</div>
</div>
I need the image that's inside of layer-3
to blend with layer-1
. If you remove the z-index from layer-2
in the fiddle, you will see that the blending works properly; however, this is not an option for accessibility reasons, as stated above.
I have made a jsfiddle here: https://jsfiddle.net/gabranches/v6cuL2o4/44/
Is there some way around this, or is this just a limitation of mix-blend-mode
?