Search code examples
csssafarimix-blend-mode

How to fix Safari mix-blend-mode: color-dodge bug?


I want to achieve some text that sits on top of an image and using mix-blend-mode: color-dodge to make the text looks better.

Here is the example: https://codepen.io/pizza0502/pen/KepWGM

enter image description here

It works perfectly in Chrome and Firefox, but in Safari, the text that is not on top of the image will become white...any solution on this?


Solution

  • Wrap your items in a container, isolate the container, and don't absolutely position your h1.

    div {
      isolation: isolate;
    }
    
    h1 {
      font-size: 10rem;
      color: #fb4b6b;
      mix-blend-mode: color-dodge;
    }
    
    img {
      position: absolute;
      top: 200px;
      z-index: -1;
    }
    <div>
      <h1>Hello Mix Blend Mode</h1>
      <img src="https://source.unsplash.com/random"/>
    </div>