Please take a look at the image below:
Imagine the blue rectangle at the bottom, with mix-blend-mode: difference, is slowly moving up towards the top. I would like it to ignore the red stripe and stay blue when crossing it, but use the mix-blend-mode for when it is on the green stripe. How would I go about doing this?
2
Answers
To make the mix-blend-mode property ignore certain backgrounds and apply only to specific elements, you can use the CSS isolation property which allows you to control the stacking context of an element and determine how it interacts with its parent and sibling elements.
Add
isolation: isolate;
to the blue rectangle css.You can put the mix-blend-mode on the rectangle where you want the blue rectangle to change and leave it off the one that is not to change the blue rectangle.
Here’s a simple example: