我正在尝试使用SVG图像作为background-image
来实现关闭按钮。以下是我正在使用的代码:SVG不会呈现为CSS背景图像
.close-button {
width: 16px;
height: 16px;
background-image: url(data:image/svg+xml;base64,[The data for the image]);
background-size: 16px 16px;
background-position: center center;
}
<span class="close-button"></span>
您可以测试它here。
它变成了一个16×16的span
,但图像没有渲染。这是为什么发生?此外,图像原本是黑色填充的。我想改变它的填充为白色。有什么办法可以做到这一点?
所以,我的问题是:
- 为什么不将图像渲染为背景?
- 如何更改在
:hover
上的SVG填充? (给我的配置 - 可以在上面的链接)
svg的外观如何? – philipp 2014-09-20 09:26:40
http://www.fileformat.info/info/unicode/char/274c/cross_mark.svg – Victor 2014-09-20 09:27:35