我有不同颜色的图像。在adobe photoshop中,我的图像用智能滤镜过滤,滤镜可以给图像添加色调、饱和度和亮度。所以我需要把图像上的所有颜色都改成蓝色。但在css hue-rotate()函数中,旋转所有颜色,但我需要设置一种颜色并更改一些饱和度和亮度。这是源图像:html - 如何使用CSS滤镜将具有不同颜色的图像色调更改为蓝色色调-LMLPHP
我需要得到这个:html - 如何使用CSS滤镜将具有不同颜色的图像色调更改为蓝色色调-LMLPHP
如何使用css过滤器在图像上设置一种色调?

最佳答案

您可以考虑mix-blend-mode属性。
使用伪元素和背景图像:

.img {
  background-image: url("https://i.stack.imgur.com/lMWO8.png");
  width: 1280px;
  height: 302px;
  position: relative;
}
.img::before, .img::after {
  content: '';
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
}
.img::before {
  background-color: gray;
  mix-blend-mode: color;
}
.img::after {
  mix-blend-mode: overlay;
  background-color: green;
}

  <div class="img"></div>

或img标签。
.cont {
  position: relative;
  width: 1280px;
  height: 302px;
}

.origin, .color-overlay--1, .color-overlay--2 {
  position: absolute;
  left:0;
  top:0;
  width: 100%;
  height: 100%;
}

.origin {
  z-index:1;
}

.color-overlay--1 {
  z-index:2;
  background-color:gray;
  mix-blend-mode:color;
}

.color-overlay--2 {
  z-index:3;
  mix-blend-mode:overlay;
  background-color:#98aeea;
}

<div class="cont">
  <img src="https://i.stack.imgur.com/lMWO8.png" alt="" class="origin">
  <div class="color-overlay--1"></div>
  <div class="color-overlay--2"></div>
</div>

所以你可以把它变成任何你想要的颜色。
.cont {
  position: relative;
  width: 1280px;
  height: 302px;
}

.origin, .color-overlay--1, .color-overlay--2 {
  position: absolute;
  left:0;
  top:0;
  width: 100%;
  height: 100%;
}

.origin {
  z-index:1;
}

.color-overlay--1 {
  z-index:2;
  background-color:gray;
  mix-blend-mode:color;
}

.color-overlay--2 {
  z-index:3;
  mix-blend-mode:overlay;
  background-color:red;
}

<div class="cont">
  <img src="https://i.stack.imgur.com/lMWO8.png" alt="" class="origin">
  <div class="color-overlay--1"></div>
  <div class="color-overlay--2"></div>
</div>

关于html - 如何使用CSS滤镜将具有不同颜色的图像色调更改为蓝色色调,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57347508/

10-13 00:44