gpt4 book ai didi

html - 如何在保持文本不透明的同时应用混合混合模式?

转载 作者:太空宇宙 更新时间:2023-11-04 15:54:08 25 4
gpt4 key购买 nike

我需要一些帮助在 CSS 中重新创建它(如果可能的话):

this

这是我目前所拥有的:

.bg {
background-image: url('https://images.unsplash.com/photo-1501706362039-c06b2d715385?auto=format&fit=crop&w=1070&q=60&ixid=dW5zcGxhc2guY29tOzs7Ozs%3D');
background-repeat: no-repeat;
background-position: center center;
padding: 100px 50px;
}

.text {
background: #ed1c24;
mix-blend-mode: multiply;
}

.text p {
font-family: "Helvetica";
font-weight: bold;
font-size: 32px;
color: #fff;
margin: 0;
padding: 40px;
}
<div class="bg">
<div class="text">
<p>
These artistic movements were a refelection of the million of people who lived and worked here. To them, "I ❤ NY" could be read as a rallying cry.
</p>
</div>
</div>

有一个带有背景图像的 div,覆盖该 div 的是另一个具有红色 bg 颜色和 mix-blend-mode: multiply 的 div。看起来颜色混合工作正常,但有没有办法让白色文本不受影响,并像示例图像中那样变成不透明的纯白色?

最佳答案

您可以使用伪元素并像这样对其应用 mix-blend-mode: multiply :

.bg {
background-image: url('https://images.unsplash.com/photo-1501706362039-c06b2d715385?auto=format&fit=crop&w=1070&q=60&ixid=dW5zcGxhc2guY29tOzs7Ozs%3D');
background-repeat: no-repeat;
background-position: center center;
padding: 100px 50px;
}

.text {
position: relative;
}

.text:before {
content: "";
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
background: #ed1c24;
mix-blend-mode: multiply;
z-index: 0;
}

.text p {
font-family: "Helvetica";
font-weight: bold;
font-size: 32px;
color: #fff;
margin: 0;
padding: 40px;
z-index: 2;
position: relative;
}
<div class="bg">
<div class="text">
<p>
These artistic movements were a refelection of the million of people who lived and worked here. To them, "I ❤ NY" could be read as a rallying cry.
</p>
</div>
</div>

关于html - 如何在保持文本不透明的同时应用混合混合模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47316364/

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