HTML / CSS 中的部分图像不透明
我想知道是否可以仅影响图像中某种颜色的不透明度?
例如,我有一个 PNG 图像文件,上面有一个简单的绘图(笑脸),我将背景仅设置为“白色”。我想在网页上使用该图像,但我只想显示笑脸(没有白色背景)。
有办法做到这一点吗?
I want to know if it is possible to affect the opacity of only a certain color in an Image?
For example, I have a PNG image file that has a simple drawing on it (smiley face) and I set the backdrop to the color 'white' only. I want to use the image on a web page, but I want only the smiley face shown (no white backdrop).
Is there a way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不是在 HTML 或 CSS 中,但您应该做的是在支持 PNG 透明度的图片编辑器中打开图像,并将图像背景设置为
transparent
(或opacity
= 0)白色的。Not in HTML or CSS but what you should do is open the image in a picture editor that supports PNG transparency and set your image background to
transparent
(oropacity
= 0) instead of white.不是用CSS。处理这个问题的最好方法是给你的笑脸图像一个透明的背景。这样,每当您想要更改其颜色时,您都可以在其后面放置一个彩色元素。
Not with CSS. The best way to handle this would be to give your smiley face image a transparent background. That way, you could put a colored element behind it whenever you want to change its color.