Html 透明图像 - 背景色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14446312/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 05:07:06  来源:igfitidea点击:

Transparent image - background color

htmlcss

提问by Mia

I'm wondering if it is possible to set a background color for transparent images? (only the image will have background color)

我想知道是否可以为透明图像设置背景颜色?(只有图像会有背景颜色)

回答by Niet the Dark Absol

If I understand you right, you can do this:

如果我理解正确,你可以这样做:

<img src="image.png" style="background-color:red;" />

In fact, you can even apply a whole background-imageto the image, resulting in two "layers" without the need for multi-background support in the browser ;)

事实上,你甚至可以将一个整体应用background-image到图像上,从而产生两个“层”,而无需浏览器中的多背景支持;)