The photo lost its colour. transform was to blame
of CSS was enough to bring the red back
In short
A black-and-white photo was meant to turn red through mix-blend-mode: multiply. When I made it move slightly with the cursor, the red disappeared. The culprit was transform, which cut the photo off from the background underneath. One line of CSS fixed it.
I was building a concept website for a music band. The band is made up, it is called Echo Arkad, and its first screen shows the arcades of townhouses in Zamość. The photo was meant to look like a two-colour poster: black and deep red instead of an ordinary photograph.
Two colours from one photo
You need no designer and no extra file for this. Three things in CSS are enough:
- A red background under the photo.
- The photo in greyscale with extra contrast, that is
filter: grayscale(1) contrast(1.25). - Multiplying the colours, that is
mix-blend-mode: multiply. White in the photo lets the red through, black stays black, and the greys become darker shades of red.
I can change the colour with one variable and the photo stays the same. It worked until I added movement.
The movement that took the colour away
On a computer, the photo was meant to shift slightly against the cursor while the band name moved with it. It gives a sense of depth. So the photo layer got a transform with an offset worked out from the mouse position.
After a refresh the photo moved, but it was plain black and white. The red was gone, even though the background was still red and the photo still had multiply.
Why this happens
mix-blend-mode does not blend an element with everything below it on screen. It only blends it with what is inside its own group of layers. Any element that has one of these, among others, starts a separate group:
transform,opacitybelow 1,filter,will-changewith one of these properties,isolation: isolate, which does it on purpose.
My photo layer got a transform, so it became its own group. Inside it there was nothing under the photo, only transparency. Multiplying by transparency does not change the image, so what was left was a plain black-and-white photo. The red section background now sat outside the group and no longer counted.
A one-line fix
If the photo only blends with what is inside its group, the red has to be inside that group. The moving layer got its own background:
.hero-foto {
background: var(--field); /* the red */
transform: translate(...);
}The photo now multiplies with the background of its own layer and is red again. As a bonus, the effect no longer depends on what sits higher up in the page’s code.
How to track down a bug like this
When a blending effect suddenly disappears, I do not look for the bug in mix-blend-mode itself. I check the elements between the blended image and the background it was meant to blend with. One of them almost always has a property from the list above. Most often it is an animation or a will-change added to make the movement smoother.
If something on your website stopped looking like the design and nobody knows why, get in touch. Problems like this usually have one specific cause.