【问题标题】:mix-blend-mode doesn't work on Chrome混合模式在 Chrome 上不起作用
【发布时间】:2018-07-02 16:40:16
【问题描述】:

我在 Chrome 上遇到了混合混合模式的问题。它不能正常工作。 另一方面,在 Firefox 和 safari 上,它可以正常工作。 我想实现抠图文字效果。 感谢您的帮助!

h1 {
  mix-blend-mode: screen;
  background: white;
  color: black;
}

body {
  background: url("https://images.unsplash.com/photo-1530518854704-23de978d2915?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=6a5e654b18d678b37850cefea5872008&auto=format&fit=crop&w=2477&q=80")
    no-repeat left / cover;
}

h1 {
  font-family: "Righteous", cursive;
  mix-blend-mode: screen;
  display: flex;
  flex-flow: column;
  padding: 0.5em;
  margin: 0;
  font-size: 6em;
  line-height: 0.95;
  background: white;
  color: black;
  text-transform: uppercase;
  max-width: max-content;
}
<h1>
  <span>Simple</span>
  <span>Cutout</span>
  <span>Heading</span>
  <span>Effect</span>
</h1>

这是codepen上的工作代码

【问题讨论】:

    标签: css mix-blend-mode


    【解决方案1】:

    Chrome 在 mix-blend-mode 和 body 方面存在一些问题

    为图像使用中间 div

    .base {
      background: url("https://images.unsplash.com/photo-1530518854704-23de978d2915?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=6a5e654b18d678b37850cefea5872008&auto=format&fit=crop&w=2477&q=80")
        no-repeat left / cover;
    }
    
    h1 {
      font-family: "Righteous", cursive;
      mix-blend-mode: screen;
      display: flex;
      flex-flow: column;
      padding: 0.5em;
      margin: 0;
      font-size: 6em;
      line-height: 0.95;
      background: white;
      color: black;
      text-transform: uppercase;
      max-width: max-content;
    }
    <div class="base">
    <h1>
      <span>Simple</span>
      <span>Cutout</span>
      <span>Heading</span>
      <span>Effect</span>
    </h1>
    </div>

    【讨论】:

    • 从 Chrome 79 开始仍然是一个问题。就好像在 mix-blend-mode 计算中忽略了 &lt;body&gt;。对于解决方法,使用body::after 也是一种选择——因此不必编辑 HTML。演示:codepen.io/fabswt/pen/BaypwZx
    • 这个问题在 2021 年仍未得到解决真是太愚蠢了。感谢你们俩的解决方法!
    • Chrome 团队有时慢得令人难以置信
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-05-09
    • 1970-01-01
    • 1970-01-01
    • 2020-07-05
    • 2021-02-08
    • 2020-02-05
    • 1970-01-01
    相关资源
    最近更新 更多