模仿Photoshop混合效果,如乘法,叠加等

Pie*_*ter 14 css photoshop overlay blend

我正在制作一个带有整页背景图片的网站.我想为侧栏创建一个背景图像,其作用类似于Photoshop图层,具有乘法混合模式.它只是一个蓝色的表面,具有Photoshop多层的"行为".

由于当以另一个屏幕比例/大小打开网站时背景可能会发生变化,因此无法合并叠加层和图像.

在此输入图像描述

在SO上有很多解决方案,但它们只能将2个图像与固定位置相乘,而不是具有可变位置/背景的彩色表面.

是否有诀窍来实现这一目标?

Rok*_*jan 5

jsBin演示

使用CSS3属性MDN文档 (要进行后备广告,请使用或具有一点Alpha透明度的颜色。)mix-blend-mode
rgbahsla

为您的元素分配所需的blend- *类,例如:

/* ::: BLEND MODE CLASSES */

.blend-normal{ mix-blend-mode: normal; }
.blend-multiply{ mix-blend-mode: multiply; }
.blend-screen{ mix-blend-mode: screen; }
.blend-overlay{ mix-blend-mode: overlay; }
.blend-darken{ mix-blend-mode: darken; }
.blend-lighten{ mix-blend-mode: lighten; }
.blend-colordodge{ mix-blend-mode: color-dodge; }
.blend-colorburn{ mix-blend-mode: color-burn; }
.blend-hardlight{ mix-blend-mode: hard-light; }
.blend-softlight{ mix-blend-mode: soft-light; }
.blend-difference{ mix-blend-mode: difference; }
.blend-exclusion{ mix-blend-mode: exclusion; }
.blend-hue{ mix-blend-mode: hue; }
.blend-saturation{ mix-blend-mode: saturation; }
.blend-color{ mix-blend-mode: color; }
.blend-luminosity{ mix-blend-mode: luminosity; }


/* ::: SET HERE YOUR INITIAL COLORS */
div{  
  background: rgba(0, 80, 200, 0.8);
  color:      #fff;
}
div span{
  color:#000;
}


/* ::: FOR DEMO ONLY */
html, body{margin:0; height:100%;font:100%/1 sans-serif;}
body{background: url(http://i.stack.imgur.com/cBy6q.jpg)fixed 50%/cover;}
div{font-size:2.2em; padding:20px; margin:15px;}
div:first-of-type{margin-top:150px;}
div:last-of-type{margin-bottom:150px;}
Run Code Online (Sandbox Code Playgroud)
<div class="">(rgba) <span>(rgba)</span></div>
<div class="blend-normal">normal <span>normal</span></div>
<div class="blend-multiply">multiply <span>multiply</span></div>
<div class="blend-screen">screen <span>screen</span></div>
<div class="blend-overlay">overlay <span>overlay</span></div>
<div class="blend-darken">darken <span>darken</span></div>
<div class="blend-lighten">lighten <span>lighten</span></div>
<div class="blend-colordodge">color-dodge <span>color-dodge</span></div>
<div class="blend-colorburn">color-burn <span>color-burn</span></div>
<div class="blend-hardlight">hard-light <span>hard-light</span></div>
<div class="blend-softlight">soft-light <span>soft-light</span></div>
<div class="blend-difference">difference <span>difference</span></div>
<div class="blend-exclusion">exclusion <span>exclusion</span></div>
<div class="blend-hue">hue <span>hue</span></div>
<div class="blend-saturation">saturation <span>saturation</span></div>
<div class="blend-color">color <span>color</span></div>
<div class="blend-luminosity">luminosity <span>luminosity</span></div>
Run Code Online (Sandbox Code Playgroud)

CSS混合模式,例如Photoshop乘积叠加减淡


Nek*_*kto 1

正如 FC 所说,您可以使用 CSS3 自定义过滤器或 SVG/Canvas。

但如果你需要一个跨浏览器的混合图层解决方案,你必须使用 JS 方法。例如,Pixastic 的 JS 图像处理脚本:http://www.pixastic.com/lib/docs/actions/blend/

此外它还有很多其他视觉效果,如模糊、噪点、裁剪、马赛克等。

我之前在几个项目中使用过这个脚本,它的效果非常好:)

希望对你有帮助)