Modernizr: blend-mode

Created on 7 Jul 2014  Â·  10Comments  Â·  Source: Modernizr/Modernizr

add test to background-blend-mode and mix-blend-mode css properties.

Most helpful comment

One way you could test for support is by using @supports, as suggested here:
http://stackoverflow.com/a/28088291/673457

@supports not (mix-blend-mode: multiply) {
  // fallback styles
}

This will work in most modern browsers, but not IE 11 or below:
http://caniuse.com/#feat=css-featurequeries

All 10 comments

and mix-blend-mode?

Unfortunatly, "[...] in some browsers, mix-blend-mode is implemented; the property is valid, the automated tests pass, but no blending actually takes place" - http://blogs.adobe.com/webplatform/2013/09/12/browser-support-matrix-for-css-blending/

@patrickkettner I see the branch that you merged that "fixes #1388". However, I just downloaded the latest from modernizr.com/download and not seeing anything for in my page for background-blend-mode. I was expecting a class to be added to <html>. Is this currently supported?

For someone needing a solution for detecting background-blend-mode, this worked for me

if(!('backgroundBlendMode' in document.body.style)) {
    // No support for background-blend-mode
  var html = document.getElementsByTagName("html")[0];
  html.className = html.className + " no-background-blend-mode";
}

@isaacwebfix we landed a detect for this in master, that is more of less what you suggested

I'm still having issues with mix-blend-mode. Could this ever be worked around??

Having a project where I need to test for mix-blend-mode specifically. Hope this will get resolved one day :) If I'm correct this issue persists due to browser vendors?

@dustindowell22 no, no detect has been created yet
@SndrL less the vendors fault as much as we just lack an API to accurately detect colors. You _might_ be able to render it inside of a foreignObject in an SVG element inside of canvas, then check the pixel value, but I have taken zero time to actually test that theory. It is a bit gross as it requires a number of other browser features to work in order to check.

One way you could test for support is by using @supports, as suggested here:
http://stackoverflow.com/a/28088291/673457

@supports not (mix-blend-mode: multiply) {
  // fallback styles
}

This will work in most modern browsers, but not IE 11 or below:
http://caniuse.com/#feat=css-featurequeries

IE11 doesn't support background-blend-mode – but also not @supports,
so here a JavaScript based test is necessary.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

claudchan picture claudchan  Â·  7Comments

peterwilsoncc picture peterwilsoncc  Â·  9Comments

BasJan81 picture BasJan81  Â·  9Comments

YounesKeraressi picture YounesKeraressi  Â·  8Comments

chrisbell08 picture chrisbell08  Â·  6Comments