「及時」模式:全新世代的 Tailwind CSS
Tailwind CSS on GitHub

Mix Blend Mode

Tailwind CSS version
v2.1+

Utilities for controlling how an element should blend with the background.

Default class reference

Class
屬性
mix-blend-normalmix-blend-mode: normal;
mix-blend-multiplymix-blend-mode: multiply;
mix-blend-screenmix-blend-mode: screen;
mix-blend-overlaymix-blend-mode: overlay;
mix-blend-darkenmix-blend-mode: darken;
mix-blend-lightenmix-blend-mode: lighten;
mix-blend-color-dodgemix-blend-mode: color-dodge;
mix-blend-color-burnmix-blend-mode: color-burn;
mix-blend-hard-lightmix-blend-mode: hard-light;
mix-blend-soft-lightmix-blend-mode: soft-light;
mix-blend-differencemix-blend-mode: difference;
mix-blend-exclusionmix-blend-mode: exclusion;
mix-blend-huemix-blend-mode: hue;
mix-blend-saturationmix-blend-mode: saturation;
mix-blend-colormix-blend-mode: color;
mix-blend-luminositymix-blend-mode: luminosity;

Usage

Use the mix-blend-{mode} utilities to control how an element’s content should be blended with the background.

<div class="bg-green-300 ...">
  <div class="mix-blend-multiply bg-amber-300 ..."></div>
</div>

Responsive

To control the mix-blend-mode property at a specific breakpoint, add a {screen}: prefix to any existing mix-blend-mode utility. For example, use md:mix-blend-overlay to apply the mix-blend-overlay utility at only medium screen sizes and above.

<div class="mix-blend-multiply md:mix-blend-overlay ...">
  <!-- ... -->
</div>

For more information about Tailwind’s responsive design features, check out the Responsive Design documentation.

Customizing

Variants

默認情況下, 只有 響應式 的 mix-blend-mode 變化模式 (variants) 會產生。

tailwind.config.jsvariants 區塊中變更 mixBlendMode 屬性來決定有哪些變化模式會生成。

舉個例子來說,這個設定將會生成 響應式 和 hover 的變化模式。

  // tailwind.config.js
  module.exports = {
    variants: {
      extend: {
        // ...
+       mixBlendMode: ['responsive', 'hover'],
      }
    }
  }

Disabling

如果你不打算在專案中使用 mix-blend-mode 功能,可以在你的設定檔裡的 corePlugins 屬性中將 mixBlendMode 設定為 false 來停用功能:

  // tailwind.config.js
  module.exports = {
    corePlugins: {
      // ...
+     mixBlendMode: false,
    }
  }