SVG背景图像
问题描述:
我有这个SASS:SVG背景图像
.menu-inner .item-block .item-inner{
border: none;
background-image: url(data:image/svg+xml;charset=utf-8,<svg%20xmlns='http://www.w3.org/2000/svg'%…20'><path%20d='M2,20l-2-2l8-8L0,2l2-2l10,10L2,20z'%20fill='%23fff'/></svg>);
}
但它不工作,我不断收到错误。 expected a variable name (e.g. $x) or ')' for the parameter list for url
我缺少什么?
答
SASS试图解释你的SVG为CSS /上海社会科学院。你应该在url
的论点上加引号。由于SVG源代码中有单引号,因此在该参数周围使用双引号。
.menu-inner .item-block .item-inner{
border: none;
background-image: url("data:image/svg+xml;charset=utf-8,<svg%20xmlns='http://www.w3.org/2000/svg'%…20'><path%20d='M2,20l-2-2l8-8L0,2l2-2l10,10L2,20z'%20fill='%23fff'/></svg>");
}
另外,SVG中的…
字符似乎不合适。
你有你的实际SASS这些URL编码字符('%20')和UTF8字符('...')?或者是复制+粘贴错误? –
它编码没有任何复制粘贴错误。 –
你能尝试这样 背景图像:URL(“数据:图像/ SVG + xml的;字符集= UTF-8,“); –