CSS background-blend-mode 属性
CSS background-blend-mode 属性定义该元素的背景图片,以及背景色如何混合。
混合模式应该按 background-image 属性同样的顺序定义。如果混合模式数量与背景图像的数量不相等,它会被截取至相等的数量。
实例
把背景图像的混合模式指定为 "lighten"(变亮):
<!DOCTYPE html><html><head><style>#myDIV {width: 400px;height: 400px;background-repeat: no-repeat, repeat;background-image: url("/images/img_tree.gif"), url("/images/paper.gif");background-blend-mode: lighten;}</style></head><body><h1>background-blend-mode 属性</h1><div id="myDIV"></div><p><b>注释:</b>79 之前的 Edge 不支持 background-blend-mode 属性。</p></body></html>
定义和用法
background-blend-mode 属性定义每个背景层(颜色和/或图像)的混合模式。
| 默认值: | normal |
|---|---|
| 继承: | 否 |
| 动画制作: | 不支持。请参阅:动画相关属性。 |
| 版本: | CSS3 |
| JavaScript 语法: | object.style.backgroundBlendMode="screen" |
浏览器支持
表格中的数字注明了完全支持该属性的首个浏览器版本。
| 属性 | |||||
|---|---|---|---|---|---|
| background-blend-mode | 35.0 | 79.0 | 30.0 | 7.1 | 22.0 |
CSS 语法
background-blend-mode: normal|multiply|screen|overlay|darken|lighten|color-dodge|saturation|color|luminosity;
属性值
| 值 | 描述 |
|---|---|
| normal | 默认。把混合模式设置为普通。 |
| multiply | 把混合模式设置为 multiply(乘)。 |
| screen | 把混合模式设置为 screen(屏幕)。 |
| overlay | 把混合模式设置为 overlay(覆盖)。 |
| darken | 把混合模式设置为 overlay(覆盖)。 |
| lighten | 把混合模式设置为 lighten(变亮)。 |
| color-dodge | 把混合模式设置为 color-dodge(颜色减淡)。 |
| saturation | 把混合模式设置为 saturation(饱和度)。 |
| color | 把混合模式设置为 color(颜色)。 |
| luminosity | 把混合模式设置为 luminosity(亮度)。 |
更多实例
把混合模式指定为 "multiply":
<!DOCTYPE html><html><head><style>#myDIV {width: 400px;height: 400px;background-repeat: no-repeat, repeat;background-image: url("/images/img_tree.gif"), url("/images/paper.gif");background-blend-mode: multiply;}</style></head><body><div id="myDIV"></div><p><b>注释:</b>79 之前的 Edge 不支持 background-blend-mode 属性。</p></body></html>
把混合模式指定为 "screen":
<!DOCTYPE html><html><head><style>#myDIV {width: 400px;height: 400px;background-repeat: no-repeat, repeat;background-image: url("/i/photo/tree.png"), url("/i/paper.gif");background-blend-mode: screen;}</style></head><body><div id="myDIV"></div><p><b>注释:</b>79 之前的 Edge 不支持 background-blend-mode 属性。</p></body></html>
把混合模式指定为 "overlay":
<!DOCTYPE html><html><head><style>#myDIV {width: 400px;height: 400px;background-repeat: no-repeat, repeat;background-image: url("/images/img_tree.gif"), url("/images/paper.gif");background-blend-mode: overlay;}</style></head><body><div id="myDIV"></div><p><b>注释:</b>79 之前的 Edge 不支持 background-blend-mode 属性。</p></body></html>
把混合模式指定为 "darken":
<!DOCTYPE html><html><head><style>#myDIV {width: 400px;height: 400px;background-repeat: no-repeat, repeat;background-image: url("/images/img_tree.gif"), url("/images/paper.gif");background-blend-mode: darken;}</style></head><body><div id="myDIV"></div><p><b>注释:</b>79 之前的 Edge 不支持 background-blend-mode 属性。</p></body></html>
把混合模式指定为 "color-dodge":
<!DOCTYPE html><html><head><style>#myDIV {width: 400px;height: 400px;background-repeat: no-repeat, repeat;background-image: url("/images/img_tree.gif"), url("/images/paper.gif");background-blend-mode: color-dodge;}</style></head><body><div id="myDIV"></div><p><b>注释:</b>79 之前的 Edge 不支持 background-blend-mode 属性。</p></body></html>
把混合模式指定为 "saturation":
<!DOCTYPE html><html><head><style>#myDIV {width: 400px;height: 400px;background-repeat: no-repeat, repeat;background-image: url("/images/img_tree.gif"), url("/images/paper.gif");background-blend-mode: saturation;}</style></head><body><div id="myDIV"></div><p><b>注释:</b>79 之前的 Edge 不支持 background-blend-mode 属性。</p></body></html>
把混合模式指定为 "color":
<!DOCTYPE html><html><head><style>#myDIV {width: 400px;height: 400px;background-repeat: no-repeat, repeat;background-image: url("/images/img_tree.gif"), url("/images/paper.gif");background-blend-mode: color;}</style></head><body><div id="myDIV"></div><p><b>注释:</b>79 之前的 Edge 不支持 background-blend-mode 属性。</p></body></html>
把混合模式指定为 "luminosity":
<!DOCTYPE html><html><head><style>#myDIV {width: 400px;height: 400px;background-repeat: no-repeat, repeat;background-image: url("/images/img_tree.gif"), url("/images/paper.gif");background-blend-mode: luminosity;}</style></head><body><div id="myDIV"></div><p><b>注释:</b>79 之前的 Edge 不支持 background-blend-mode 属性。</p></body></html>
把混合模式指定为 "normal":
<!DOCTYPE html><html><head><style>#myDIV {width: 400px;height: 400px;background-repeat: no-repeat, repeat;background-image: url("/images/img_tree.gif"), url("/images/paper.gif");background-blend-mode: normal;}</style></head><body><div id="myDIV"></div><p><b>注释:</b>79 之前的 Edge 不支持 background-blend-mode 属性。</p></body></html>
相关页面
CSS 教程:CSS 背景