RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题 / 785986
Accepted
Alexey Giryayev
Alexey Giryayev
Asked:2020-02-16 19:17:27 +0000 UTC2020-02-16 19:17:27 +0000 UTC 2020-02-16 19:17:27 +0000 UTC

乘以 img(灰色背景上的白色背景图像叠加)

  • 772

因此,通常需要在灰色背景上叠加图像,例如产品项目。同时,我们有一个白色的背景,这往往不适合页面的设计。用于理解问题的图片:

在此处输入图像描述

有什么方法可以<img>类比在灰色背景上叠加background-blend-mode: multiply?

一段带有外观的 HTML,因此不会尝试简单地复制上图中的内容:

body {
margin: 0;
padding: 0;
background: #f6f6f6;
text-align: center;
}
img {
max-width: 240px;
margin: 60px;
}
<img src="https://isstatic.askoverflow.dev/iunPY.jpg" />

css
  • 4 4 个回答
  • 10 Views

4 个回答

  • Voted
  1. Sasha Omelchenko
    2020-02-16T22:18:37Z2020-02-16T22:18:37Z

    是的,这是一个属性mix-blend-mode: multiply。

    figure {
      margin: 0;
      padding: 0;
      position: relative;
    }
    
    figure img {
      mix-blend-mode: multiply;
      display: block;
    }
    
    figure:before {
      position: absolute;
      content: ' ';
      right: 0;
      width: 50%;
      height: 100%;
      background: #CCC;
      z-index: -1;
    }
    <figure>
      <img src="https://media.istockphoto.com/photos/handsome-young-man-on-white-background-picture-id523478288?k=6&m=523478288&s=612x612&w=0&h=4JptiegzwJp1nA1ItdZSogOmqVqC02ZCFTCI32VrDDY=" />
    </figure>

    • 3
  2. Best Answer
    Alexander Goroshev
    2020-02-16T21:15:51Z2020-02-16T21:15:51Z

    目前,解决问题的最简单和最平庸的方法是用透明背景覆盖图像:

    body {
      margin: 0;
      padding: 0;
      background: #f6f6f6;
      text-align: center;
    }
    
    img {
      max-width: 240px;
      margin: 60px;
    }
    
    div {
      position: absolute;
      width: 120px;
      height: 240px;
      background: rgba(30, 30, 30, .04);
      left: 50%;
      top: 60px;
    }
    <img src="https://isstatic.askoverflow.dev/iunPY.jpg" />
    <div></div>

    在这种情况下,在使用这些值之后,我完全达到了预期的结果,没有损失对比度和复杂的“拐杖”。应用范围可以非常多样化。如果没有人想出更好的东西,我很乐意接受它作为正确答案。

    • 2
  3. Kniha m
    2020-02-16T19:33:09Z2020-02-16T19:33:09Z

    你可以这样做:

    .image {
      position: relative;
      display: inline-block;
    }
    
    .image> div {
      position: absolute;
      top: 0;
      bottom: 0;
      left: 0;
      width: 50%;
      overflow: hidden;
      background: gray; /*Задать фон для png, отличный от основного*/
    }
    
    .image-slider img {
      display: block;
    }
    <div class="image">
      <div>
        <img src="https://vignette.wikia.nocookie.net/chelovechestorona/images/b/b9/Bill_cipher_cat_by_ink_n_heart-d7mx1b5.png/revision/latest/scale-to-width-down/640?cb=20141006131434&path-prefix=ru" alt="" />
      </div>
      <img src="https://vignette.wikia.nocookie.net/bakugan/images/2/2e/Aquos_Olifus.png/revision/latest?cb=20110223133315" alt="" />
    </div>

    • 0
  4. zhurof
    2020-02-16T20:01:53Z2020-02-16T20:01:53Z

    使用 css 您不会更改光栅图像的各个部分(请参见白色背景),在您的情况下仅使用png.

    .card{
      width:200px;
      height:200px;
      background:
        url(https://www.be-in.ru/media/beingallery/gallary/things/2014/03/12/DSC_6803.png.590x700_q95.png) no-repeat center/100px auto,
        linear-gradient(90deg,white 50%,gray 50%);
      border:1px solid;
      position:relative;
    }
    .card:before{
      content:'';
      display:block;
      position:absolute;
      top:0;
      left:calc(50% - 1px);
      height:100%;
      border-right:2px solid rgba(0,0,0,.3);
    }
    <div class="card"></div>

    • 0

相关问题

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    是否可以在 C++ 中继承类 <---> 结构?

    • 2 个回答
  • Marko Smith

    这种神经网络架构适合文本分类吗?

    • 1 个回答
  • Marko Smith

    为什么分配的工作方式不同?

    • 3 个回答
  • Marko Smith

    控制台中的光标坐标

    • 1 个回答
  • Marko Smith

    如何在 C++ 中删除类的实例?

    • 4 个回答
  • Marko Smith

    点是否属于线段的问题

    • 2 个回答
  • Marko Smith

    json结构错误

    • 1 个回答
  • Marko Smith

    ServiceWorker 中的“获取”事件

    • 1 个回答
  • Marko Smith

    c ++控制台应用程序exe文件[重复]

    • 1 个回答
  • Marko Smith

    按多列从sql表中选择

    • 1 个回答
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Suvitruf - Andrei Apanasik 什么是空? 2020-08-21 01:48:09 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5