主题
  • 默认模式
  • 浅蓝色模式
  • 淡绿色模式
  • 深夜模式

定义和用法

background-blend-mode是 CSS 中用于定义元素的背景图像和背景颜色如何混合的属性。

background-blend-mode属性类似于 Photoshop 中的图层混合模式。

默认值: normal
继承性:
可动画性: 否。请参阅:可动画属性
版本: CSS3
JavaScript 语法: object.style.backgroundBlendMode="screen"

常用的实例

接下来通过多个实例演示background-blend-mode属性的用法,来深化您对background-blend-mode属性的理解。

1. 基本使用

multiply正片叠底,使背景变暗。

实例代码 运行代码
复制
.element {
    background-image: url('image.jpg');
    background-color: blue;
    background-blend-mode: multiply;
}

2. 多背景混合

screen滤色和overlay叠加,两种模式混合。

实例代码 运行代码
复制
.element {
    background-image: url('image1.jpg'), url('image2.jpg');
    background-blend-mode: screen, overlay;
}

3. 与渐变结合

overlay叠加模式,与渐变背景结合使用。

实例代码 运行代码
复制
.element {
    background-image: linear-gradient(to right, red, blue), url('pattern.png');
    background-blend-mode: overlay;
}

CSS 语法

background-blend-mode: normal|multiply|screen|overlay|darken|lighten|color-dodge|saturation|color|luminosity;

属性值

描述
normal 默认,不应用混合,背景层简单叠加。
multiply 正片叠底,将背景颜色/图像相乘,使结果变暗(类似油墨叠加)。
screen 滤色,将颜色反相后相乘再反相,使结果变亮(类似光线叠加)。
overlay 叠加,结合multiplyscreen,暗区更暗,亮区更亮,增强对比度。
darken 变暗,保留两层中较暗的像素,即保留深色部分。
lighten 变亮,保留两层中较亮的像素,即保留浅色部分。
color-dodge 颜色减淡,通过降低对比度使下层色变亮(类似减淡工具)。适用于光晕、曝光效果。
color-burn 颜色加深,通过增加对比度使下层色变暗(类似加深工具)。适用于暗角、阴影强化。
hard-light 强光,类似overlay,但以上层色为基准决定混合模式。适用于模拟强光照射。
soft-light 柔光,类似hard-light,但更柔和(类似漫反射光)。适用于自然光效、柔化图像。
difference 差值,取两层颜色的绝对差值。适用于反色效果、艺术化处理。
exclusion 排除,类似difference,但对比度更低。适用于柔和的反色效果。
hue 色相,保留上层色的色相,使用下层色的饱和度和亮度。适用于统一色调。
saturation 饱和度,保留上层色的饱和度,使用下层色的色相和亮度。适用于调整色彩鲜艳度。
color 颜色,保留上层色的色相和饱和度,使用下层色的亮度。适用于黑白图像上色。
luminosity 亮度,保留上层色的亮度,使用下层色的色相和饱和度。适用于调整明暗不影响色彩。

浏览器支持

表中的数字指定了完全支持background-blend-mode属性的第一个浏览器版本。

Chrome 浏览器 EDGE 浏览器 Firefox 浏览器 Safari 浏览器 Opera 浏览器
Chrome Edge Firefox Safari Opera
35.0 79.0 30.0 7.1 22.0

相关页面

CSS 教程:CSS 背景



评论区 0
发表评论
教程介绍
CSS 参考手册全面涵盖选择器、盒模型,文本属性等,助您快速检索 CSS 使用方法。
95 章节
167 阅读
0 评论
教程目录

CSS 参考手册

CSS 属性(字母排序) CSS 属性(功能排序) CSS 浏览器支持 CSS 选择器 CSS 函数 CSS 可动画性 CSS Web安全字体 CSS 单位 CSS 颜色 CSS 颜色值

CSS 属性

align-content align-items align-self all animation animation-delay animation-direction animation-duration animation-fill-mode animation-iteration-count animation-name animation-play-state animation-timing-function aspect-ratio backdrop-filter backface-visibility background background-attachment background-blend-mode background-clip background-color background-image background-origin background-position background-position-x background-position-y background-repeat background-size block-size border border-block border-block-color border-block-end border-block-end-color border-block-end-style border-block-end-width border-block-start border-block-start-color border-block-start-style border-block-start-width border-block-style border-block-width border-bottom border-bottom-color border-bottom-left-radius border-bottom-right-radius border-bottom-style border-bottom-width border-collapse border-color border-end-end-radius border-end-start-radius border-image border-image-outset border-image-repeat border-image-slice border-image-source border-image-width border-inline border-inline-color border-inline-end border-inline-end-color border-inline-end-style border-inline-end-width border-inline-start border-inline-start-color border-inline-start-style border-inline-start-width border-inline-style border-inline-width border-left border-left-color border-left-style border-left-width border-radius border-right border-right-color border-right-style border-right-width border-spacing border-start-end-radius border-start-start-radius border-top-left-radius border-top-right-radius border-top-style