1. 效果
  2. 混合模式

效果

混合模式(mix-blend-mode)

控制元素如何与背景混合的工具类。

ClassStyles
mix-blend-normal
mix-blend-mode: normal;
mix-blend-multiply
mix-blend-mode: multiply;
mix-blend-screen
mix-blend-mode: screen;
mix-blend-overlay
mix-blend-mode: overlay;
mix-blend-darken
mix-blend-mode: darken;
mix-blend-lighten
mix-blend-mode: lighten;
mix-blend-color-dodge
mix-blend-mode: color-dodge;
mix-blend-color-burn
mix-blend-mode: color-burn;
mix-blend-hard-light
mix-blend-mode: hard-light;
mix-blend-soft-light
mix-blend-mode: soft-light;

示例

基本示例

使用像 mix-blend-overlaymix-blend-soft-light 这样的工具类来控制元素的内容和背景与同一堆叠上下文中的其他内容如何混合:

<div class="flex justify-center -space-x-14">
<div class="bg-blue-500 mix-blend-multiply ..."></div>
<div class="bg-pink-500 mix-blend-multiply ..."></div>
</div>

隔离混合

在父元素上使用 isolate 工具类来创建一个新的堆叠上下文,并防止与其后面的内容混合:

<div class="isolate flex justify-center -space-x-14">
<div class="bg-yellow-500 mix-blend-multiply ..."></div>
<div class="bg-green-500 mix-blend-multiply ..."></div>
</div>
<div class="flex justify-center -space-x-14">
<div class="bg-yellow-500 mix-blend-multiply ..."></div>
<div class="bg-green-500 mix-blend-multiply ..."></div>
</div>

响应式设计

Prefix a mix-blend-mode utility with a breakpoint variant like md: to only apply the utility at medium screen sizes and above:

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

Learn more about using variants in the variants documentation.