简体   繁体   English

样式表中的样式base64 SVG

[英]Style base64 SVG from style sheet

So I have the following CSS to produce an SVG logo: 所以我有以下CSS来生成SVG徽标:

 background: url("data:image/svg+xml;base64,xyz.....");

Does anyone know how I can change the colour of the icon with CSS inside my style sheet, as opposed to embedded in the SVG tag. 有没有人知道如何在我的样式表中使用CSS更改图标的颜色,而不是嵌入在SVG标记中。

I'm trying to have the same logo on the page multiple times, in different colours, so don't want to have loads multiple versions of the SVG code in my style sheet. 我试图在页面上多次使用不同颜色的相同徽标,因此不希望在我的样式表中加载多个版本的SVG代码。

Thanks! 谢谢!

If you're going to be using it a lot at different sizes it might be worth making a custom icon font. 如果您要以不同的尺寸使用它,那么制作自定义图标字体可能是值得的。

Then you can style it with css and use em to keep it sized relatively etc. 然后你可以用css设置样式并使用em来保持相对大小等。

http://www.font2web.com/ etc will take an SVG. http://www.font2web.com/等将采用SVG。

As said in the comments: You can't style it with an external CSS if you display your SVG image using the base64 format. 如评论中所述:如果使用base64格式显示SVG图像,则无法使用外部CSS设置样式。 The only way is to use the original <svg> format where you can see the tags and properties, either inserted directly into your html or loaded from an external file. 唯一的方法是使用原始的<svg>格式,您可以在其中看到标签和属性,可以直接插入html或从外部文件加载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM