【发布时间】:2019-03-19 00:51:03
【问题描述】:
如何在 Chrome 中使用 %23 而不是 #?
html:
<div class="helloText">
hello text
</div>
css:
.helloText {
background: #FF8500 url( "data:image/svg+xml;charset=utf8,<svg width='100%' height='100%' viewBox='0 0 1 1' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' preserveAspectRatio='none'><polygon points='0,1 1,1 1,0' style='fill:#fff;'></polygon></svg>" );
background-repeat: no-repeat;
background-size: 36px 36px;
background-position: 100% 100%;
padding: 20px;
padding-bottom: 25px;
margin-top: 35px;
color: white;
font-family: AvenirLT65Medium;
font-size: 14pt;
}
分辨率
在这样的配置中一切正常。唯一但我在 Chrome 控制台中收到以下警告:
[弃用] 在数据 URI 正文中使用未转义的“#”字符已被弃用,并将在 2018 年 12 月左右的 M71 中删除。请改用“%23”。详情请见https://www.chromestatus.com/features/5656049583390720。
好的,我把css改成:
.helloText {
background: #FF8500 url( "data:image/svg+xml;charset=utf8,<svg width='100%' height='100%' viewBox='0 0 1 1' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' preserveAspectRatio='none'><polygon points='0,1 1,1 1,0' style='fill:%29fff;'></polygon></svg>" );
background-repeat: no-repeat;
background-size: 36px 36px;
background-position: 100% 100%;
padding: 20px;
padding-bottom: 25px;
margin-top: 35px;
color: white;
font-family: AvenirLT65Medium;
font-size: 14pt;
}
分辨率
Here 是一个小提琴。那么,如何将# 替换为%29?
另外,我想注意到here 的部分答案是错误的。
它告诉你
填充属性中的标签在我的情况下触发消息!将 # 更改为 %23 可以解决此问题。
但正如我上面解释的那样,情况并非如此。
【问题讨论】:
-
您可以只使用颜色名称而不是十六进制代码。这样您就不会收到任何错误消息。
标签: css google-chrome svg warnings hashtag