css - CSS 中的乘法模式?

标签 css background-blend-mode mix-blend-mode

在 Photoshop 中,如果将具有白色背景的 JPG 图像导入到具有蓝色背景 的文档中,您可以通过设置图像到“相乘”模式。

我可以单独使用 CSS 做同样的事情吗?

最佳答案

在 CSS 中你可以使用 mix-blend-mode

The mix-blend-mode CSS property describes how an element content should blend with the content of the element that is below it and the element's background.

片段

body {
  margin: 0;
  background: url(http://lorempixel.com/1200/1200) no-repeat 0 0 / cover
}
img {
  mix-blend-mode: multiply;
}
<img src="//placehold.it/300" />

或者您可以使用 background-blend-mode

The background-blend-mode CSS property describes how the element's background images should blend with each other and the element's background color.

片段

div {
    width: 300px;
    height: 300px;
    background: url('https://mdn.mozillademos.org/files/8543/br.png'),url('https://mdn.mozillademos.org/files/8545/tr.png');
    background-blend-mode: multiply;
}
<div></div>

IE 不支持两者,请参阅支持 herehere

关于css - CSS 中的乘法模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35943823/

相关文章:

同时使用 CSS 灰度滤镜和背景混合模式?

html - 设置了半混合模式的图像

css - 如何使用混合混合模式更改动画背景上的文本颜色

javascript - 相同的选项卡内容显示两次

javascript - 根据 Web 浏览器的大小调整对象的大小

html - 我如何在CSS中将一个容器与两个不同的容器混合

css - 将混合模式与 2 个重叠的 div 混合,但需要排除文本

html - 在视频 html/css 上应用 png 蒙版

html - 悬停按钮的媒体查询定位问题