创建主题时,RGBA色码会自动转换为Hexa code

  • 本文关键字:转换 code Hexa RGBA 创建 css
  • 更新时间 :
  • 英文 :


我使用SVG数据图像作为我的菜单图标。这里我使用"stroke='rgba(247,77,77,1)'"作为图标的颜色。我所面临的问题是,一旦我建立一个主题,斯托克颜色代码就会自动转换为十六进制代码(#F74D4D),因此图标没有出现在我的应用程序中。

谁能告诉我为什么会发生转换?

#keyword div {
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(247,77,77,1)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8h24M4 16h24M4 24h24'/%3E%3C/svg%3E")
}
<figure id="keyword">
<div></div>
</figure>

我相信你只需要将()编码为%28%29,并添加高度

#keyword div {
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba%28247,77,77,1%29' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8h24M4 16h24M4 24h24'/%3E%3C/svg%3E");
height:32px;
}
<figure id="keyword">
<div></div>
</figure>