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
Transparent image - background color
提问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-image
to the image, resulting in two "layers" without the need for multi-background support in the browser ;)
事实上,你甚至可以将一个整体应用background-image
到图像上,从而产生两个“层”,而无需浏览器中的多背景支持;)