Currently faced with the challenge of creating stacked <div>
elements where the top-level <div>
has masked content in React (although this is primarily for SVG element notation).
I have two responsively-styled <div>
s — A and B — each containing an <img>
, where B is positioned above A. I want to apply an inline, arbitrary SVG mask to <div>
B to partially reveal the content of <div>
A below it.
My goal is to achieve a visual result like this...
Two absolutely positioned <div>
s stacked on top of each other:
https://i.sstatic.net/qxQhE.png
The content of an inline <svg>
:
https://i.sstatic.net/ZZtm5.png
...Used as a mask on <div>
B to create this effect:
https://i.sstatic.net/rr48i.png
I prefer not to use clip-path
due to limited browser support, so I'm seeking a simpler approach. It's crucial that I can position the <img>
elements within the <div>
s and add more elements if necessary, rather than just setting a background mask-image
on the <svg>
.
Is there an alternative method to achieve this without using SVG <mask>
or <clipPath>
elements? If not, can more than just an <img>
be embedded in the SVG mask via SVG <image>
?