gpt4 book ai didi

css - 使用 css3 为背景图像着色

转载 作者:行者123 更新时间:2023-11-28 18:36:27 25 4
gpt4 key购买 nike

是否可以使用 css3 为灰度背景图像着色?

这是一个图标。我希望它是蓝色的。

input[name=email] { background-image: url(/static/images/icons/glyphicons_010_envelope.png); background-size: 16px auto; background-position: 8px 7px; }

最佳答案

一种可能性是在图像上叠加蓝色 + alpha 颜色。

这样做的一种可能性是:

.base {
width: 200px;
height: 200px;
background: linear-gradient(45deg, black, white, black);
}
#shadow {
box-shadow: 0px 0px 3000px 0 rgba(0,0,255,0.5) inset;
}

为了避免寻找黑白图像,我在 base 中设置了渐变。

然后,在阴影中,我创建了一个巨大的嵌入阴影,蓝色的 alpha 0.5

demo

在演示中,您可以看到基本图像和蓝色的相同图像。

解释

框阴影设置为内嵌,使其位于框内,边框周围。如果尺寸太小,您会看到盒子的中心没有阴影。

而且,由于颜色是带有 alpha 的蓝色,它有点透明,您可以透过它看到背景。

关于css - 使用 css3 为背景图像着色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12542779/

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