【发布时间】:2021-08-05 05:41:27
【问题描述】:
您好,如果背景为白色或其他情况下为黑色,我目前正在尝试找到一种解决方案,使粘性文本变为黑色。在我的研究中,我发现了混合混合模式属性,但制作我想要的东西似乎非常复杂。
.sticky {
position: -webkit-sticky;
position: sticky;
top: 20px;
color:white;
font-size:60px;
mix-blend-mode: difference;
}
.panel {
height: 80vh;
widht: 100%;
}
.bg-black {
background: black;
}
.bg-red {
background: red;
}
.bg-blue {
background: blue;
}
.bg-green {
background: green;
}
<div class="sticky">
My text
</div>
<div>
<section class="panel"></section>
<section class="panel bg-black"></section>
<section class="panel bg-red"></section>
<section class="panel bg-blue"></section>
<section class="panel bg-green"></section>
</div>
有人知道可以帮助我的 hack 或软件包吗?
非常感谢
【问题讨论】:
-
调整您的代码示例,因为没有 css 并且您的 css 在问题中被破坏。
-
嗨,这可能需要改写:“如果背景是白色或在任何其他情况下为黑色,则将文本设为黑色” - 应该是“或在其他情况下为白色”。
标签: css mix-blend-mode