答案 0 :(得分:7)
一种想法是使用反转的背景为文本着色。
以下是考虑radial-gradient
的想法:
.box {
padding: 50px;
background: radial-gradient(circle at 70% 0px, #fff 45%, purple 45.5%) fixed;
}
p {
font-size: 25px;
font-weight: bold;
/*Should be the same background but inverted color*/
background: radial-gradient(circle at 70% 0px, purple 45%, #fff 45.5%) fixed;
background-clip: text;
color: transparent;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
<div class="box">
<p>Some text here Some text here Some text here Some text here </p>
</div>
在您的情况下,背景似乎是一幅图像,因此您只需要找到一个可以转换颜色的相似渐变即可。
另一个想法是使用基本图像并添加覆盖层以创建结果:
.box {
padding: 50px;
background:
radial-gradient(circle at 70% 0px, #fff 35%, rgba(27, 128, 0, 0.6) 35.5%),
url(https://picsum.photos/500/800?image=1069) center/cover;
background-attachment:fixed;
}
p {
font-size: 25px;
font-weight: bold;
/*Should be the same background but inverted color*/
background: radial-gradient(circle at 70% 0px, rgba(27, 128, 0, 1) 35%, #fff 35.5%) fixed;
background-clip: text;
color: transparent;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
<div class="box">
<p>Some text here Some text here Some text here Some text here </p>
</div>