I have an app where I need to 'highlight' two separate rectangular areas by covering everything else with a half-transparent backdrop.
After some research I though that css clipping/masking could be used here. But seems those are solving the inverse problem (i.e. showing parts covered with mask while hiding the rest). What I need - is to somehow subtract 2 separate regions from the backdrop div
element. Kinda clip out.
The following image shows approximately what I'm trying to achieve:
p.s.
I guess that can also be achieved by having multiple rectangles within a masking svg that would form that kind of outer backdrop shape. But before this - I'm wondering maybe there's a better way. Cuz this solution would involve some serious thinking :)
Edit:
Right, I tried out the suggested solution (the one that mine was considered a duplicate of). It didn't work for my case where I needed all this to happen dynamically and be cross-browser. As I found, mask-composite
has a very limited support. In case someone is interested I found a better solution for my use-case that supports dynamic rects and has a better cross-browser support.