我想知道是否有办法让背景同时具有数据 uri 和颜色。原来,我有这样的背景……
background:#222 url('data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==');
并且我希望我的数据 url 图像的 css 颜色高于 #222
这可能吗?
更新: 对于参与回答此问题的所有人,我深表歉意。我犯了一个小错误,没有替换 data-uri 代码而不是图像路径
谢谢
最佳答案
是的,你可以使用 color + url,只要按正确的顺序写就可以了:
When using the shorthand property the order of the property values is:
background-color background-image background-repeat background-attachment background-position It does not matter if one of the property values is missing, as long as the ones that are present are in this order.
样式:
.bgnd{
width:100%;
height:100px;
background: #ccc url("https://jsfiddle.net/img/logo.png");
}
HTML:
<div class="bgnd"></div>
关于css - 数据 uri 同时使用颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29298258/