gpt4 book ai didi

html - 反转彩色文本相关背景

转载 作者:搜寻专家 更新时间:2023-10-31 23:18:32 25 4
gpt4 key购买 nike

我想根据文本的背景反转文本颜色,如下图所示:image .

所以我试过下面的代码,但是没有用:

#warp,
#text,
#tri {
position: absolute;
top: 0;
left: 0;
width: 150px;
height: 150px;
z-index: 1;
}

#warp {
background-color: orange;
}

#text {
text-align: center;
z-index: 3;
}

#text h1 {
margin: 0;
line-height: 150px;
mix-blend-mode: difference;
}

#tri {
background-color: black;
clip-path: polygon(0 0, 0 100%, 99.8% 150px);
-webkit-clip-path: polygon(0 0, 0 100%, 99.8% 150px);
z-index: 2;
}
<div id="warp">
<div id="text">
<h1>TEXT</h1>
</div>
<div id="tri"></div>
</div>

我找到了一些关于 background-image & inverted text 的结果,但我不知道如何用 DIV 来做。

最佳答案

您可以通过使用线性渐变作为背景来避免剪辑路径,mix-blend-mode 将完美地工作:

#text {
width: 150px;
height: 150px;
z-index: 1;
}

#text {
text-align: center;
background: linear-gradient(to top right, black 50%, orange 51%);
}

#text h1 {
margin: 0;
line-height: 150px;
mix-blend-mode: difference;
color: #fff;
}
<div id="text">
<h1>TEXT</h1>
</div>

关于html - 反转彩色文本相关背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49024660/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com