mix-blend-mode
Baseline Widely available *
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
* Some parts of this feature may have varying levels of support.
mix-blend-mode
CSS 属性描述了元素的内容应该与元素的直系父元素的内容和元素的背景如何混合。
尝试一下
mix-blend-mode: normal;
mix-blend-mode: multiply;
mix-blend-mode: hard-light;
mix-blend-mode: difference;
.example-container {
background-color: sandybrown;
}
语法
css
/* 关键字值 */
mix-blend-mode: normal;
mix-blend-mode: multiply;
mix-blend-mode: screen;
mix-blend-mode: overlay;
mix-blend-mode: darken;
mix-blend-mode: lighten;
mix-blend-mode: color-dodge;
mix-blend-mode: color-burn;
mix-blend-mode: hard-light;
mix-blend-mode: soft-light;
mix-blend-mode: difference;
mix-blend-mode: exclusion;
mix-blend-mode: hue;
mix-blend-mode: saturation;
mix-blend-mode: color;
mix-blend-mode: luminosity;
mix-blend-mode: plus-darker;
mix-blend-mode: plus-lighter;
/* 全局值 */
mix-blend-mode: inherit;
mix-blend-mode: initial;
mix-blend-mode: revert;
mix-blend-mode: revert-layer;
mix-blend-mode: unset;
值
形式定义
初始值 | normal |
---|---|
适用元素 | 所有元素 |
是否是继承属性 | 否 |
计算值 | as specified |
动画类型 | Not animatable |
Creates stacking context | 是 |
形式语法
示例
不同 mix-blend-mode 值的效果
HTML 中使用 mix-blend-mode
HTML
html
CSS
css
.circle {
width: 80px;
height: 80px;
border-radius: 50%;
mix-blend-mode: screen;
position: absolute;
}
.circle-1 {
background: red;
}
.circle-2 {
background: lightgreen;
left: 40px;
}
.circle-3 {
background: blue;
left: 20px;
top: 40px;
}
.isolate {
isolation: isolate; /* Without isolation, the background color will be taken into account */
position: relative;
}
结果
SVG 中使用 mix-blend-mode
SVG
html
CSS
css
circle {
mix-blend-mode: screen;
}
.isolate {
isolation: isolate;
} /* Without isolation, the background color will be taken into account */
结果
规范
Specification |
---|
Compositing and Blending Level 2 # mix-blend-mode |