9

I'm susccesfully using background-blend-mode on my header here: https://yogrow.co/ecommerce-stack

However I've noticed that the background-blend-mode is not working on iPhone. I just get no background color.

Here is the CSS I am using

background-repeat: repeat;
background-image: url("assets/img/swirl_pattern.png");
background-color: #E33551;
background-blend-mode: multiply;

Is the only / best option to use media queries to create a new set of css rules or is there an alternative way to have a fallback so for devices like iPhone Safari that do not show the color bg the background goes to a red.

Because I have white text on top of the background it currently looks illegible on the iPhone safari.

Thanks

ejntaylor
  • 1,900
  • 1
  • 25
  • 43
  • 2
    I've been running into the same problem. I have found that `background-repeat: repeat;` causes the blend mode to stop working on iOS. I don't know why, but if you set it to no-repeat, then it works. Obviously that isn't an ideal solution though. – Garconis Mar 21 '16 at 15:35
  • Thank you for sharing this tip. it fixed the problem i encountered. –  Jan 03 '17 at 13:53

4 Answers4

18

It seems like background-blend-mode not working with background-repeat: repeat;. Try to set background-repeat: no-repeat;.

1

It seems the following modes is not supported by safari for background-blend-mode: hugh, saturation,color and luminosity

I see the author of the question did not use one of the above mentioned, but it might help someone else.

Gerrie Pretorius
  • 3,381
  • 2
  • 31
  • 34
0

background-repeat: no-repeat worked for me, but in our application, the element in question could sometimes have a repeating background, so that solution was not sufficient. I found (in iOS 10.2) that any element with border-style set on it would not respect background-blend-mode; i.e., images and colors would not blend. Removing border-style (or any variants like border-bottom-style or border) fixed the issue.

Jackson
  • 9,188
  • 6
  • 52
  • 77
0

I absolutely needed background-repeat in my design. I have a transparent PNG over a solid color (a linear-gradient layer).

The workaround isn't exactly pretty: I load UAParser.js, and test for (iOS && WebKit).

<script src='https://cdnjs.cloudflare.com/ajax/libs/UAParser.js/0.7.21/ua-parser.min.js'></script>
<script>
window.workaroundBackgroundBlendMode = (function() {
  var ua = UAParser()
  var isWebKit = (ua.engine.name === "WebKit")
  var isIOS = (ua.os.name === "iOS")
  var debug = false //|| true
  var shouldActivate = (isWebKit && isIOS) || debug;

  if (shouldActivate) {
    document.body.classList.add("is-ios-webkit")
  }

  // You can inspect this returned object afterwards
  return {isWebKit, isIOS, debug, shouldActivate, ua}
})()
</script>

There will be a small lag, but I figure this is justified because it only affects the buggy clients.

Jonathan Allard
  • 18,429
  • 11
  • 54
  • 75