【问题标题】:How can I isolate my background from "mix-blend-mode"?如何将我的背景与“mix-blend-mode”隔离开来?
【发布时间】:2022-11-21 10:18:55
【问题描述】:

我偶然发现了一个我似乎无法解决的问题。我目前正在使用 mix-blend-mode: difference 在我的汉堡包菜单上,这样我就可以实现在重叠时改变颜色的效果。

如此图所示:

虽然,我只希望它在黑白之间变化。不是黑色和背景之间的差异。

我的背景是一个移动的渐变,而不是图像。如下面的代码所示。

:root {
  background-color: #1d1128;
}

body {
  margin: 0;
  display: flex;
  place-items: center;
  min-height: 100vh;
  max-width: 100%;

  -webkit-animation: backgroundAnimation 35s ease-in-out infinite;
  -moz-animation: backgroundAnimation 35s ease-in-out infinite;
  animation: backgroundAnimation 35s ease-in-out infinite;
  background-size: 175% 175%;
  background-image: radial-gradient(
      ellipse at 70% 0,
      rgba(66, 4, 126, 0.7) 0,
      rgba(60, 31, 132, 0) 30%
    ),
    radial-gradient(
      circle at 90% 0,
      rgba(7, 244, 158, 0.5) 0,
      rgba(22, 148, 102, 0) 30%
    ),
    radial-gradient(
      ellipse at 0 0,
      rgba(66, 4, 126, 0.15) 0,
      rgba(60, 185, 174, 0) 40%
    ),
    radial-gradient(
      circle at 30% 100%,
      rgba(66, 4, 126, 0.7) 0,
      rgba(60, 31, 132, 0) 40%
    ),
    radial-gradient(
      ellipse at 10% 100%,
      rgba(7, 244, 158, 0.5) 0,
      rgba(22, 148, 102, 0) 40%
    ),
    radial-gradient(
      ellipse at 100% 100%,
      rgba(60, 185, 174, 0.15) 0,
      rgba(60, 185, 174, 0) 40%
    );
}

.hamburger-menu {
  position: absolute;
  mix-blend-mode: difference;
  right: 50px;
  top: 50px;
  z-index: 501;
}

我浏览了互联网,但没有找到任何可以帮助我的东西。我读了一些关于隔离的文章,但我认为这在这种情况下行不通。因为背景是写在正文里的。

先感谢您。

【问题讨论】:

  • 您应该添加一些 HTML 并将其与您的 CSS 一起放入本文的代码片段中,以便人们可以看到您的问题,而不是查看屏幕截图并尝试盲目修复一些 css。

标签: html css vue.js mix-blend-mode


【解决方案1】:

添加 background-color 属性并查看它的作用

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-30
    • 2021-04-23
    • 2020-12-12
    • 1970-01-01
    • 1970-01-01
    • 2023-04-05
    相关资源
    最近更新 更多