[英]Difference between svg path and an image.svg
I would like to know more about svg and I have a question. 我想知道更多关于svg的问题。
For exemple, I've export a shape with Illustrator as html code so I have this : 例如,我已经将Illustrator的形状导出为html代码,所以我有以下内容:
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Calque_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 1920 600" enable-background="new 0 0 1920 600" xml:space="preserve">
<g>
<polygon fill="none" stroke="#B24539" points="0,297 0,379.3 26.9,346.1 "/>
</g>
And I want to know the difference between using svg with code like this and using an image.svg ? 我想知道将svg与这样的代码一起使用以及与image.svg之间的区别吗?
Inline SVG would allow you to target parts of your SVG with CSS: 内联SVG允许您使用CSS定位SVG的各个部分:
.svg {
fill: #fff;
}
This is not possible if the SVG was brought in with an <img>
tag. 如果SVG是通过
<img>
标签引入的,则这是不可能的。
Here's a post from CSS Tricks that talks about the many different ways you can use SVGs: https://css-tricks.com/using-svg/ 这是CSS Tricks的帖子,其中讨论了可以使用SVG的多种不同方式: https : //css-tricks.com/using-svg/
It would be best to use inline svg as @restlessbit points out, because you have more control over the style. 最好使用@restlessbit指出的内联svg,因为您可以更好地控制样式。
For example, changing background colors, adding path colors and even adding text to an SVG can be done when adding SVG inline. 例如,当内联添加SVG时,可以更改背景颜色,添加路径颜色,甚至向SVG添加文本。
Here is a post that illustrates some of these mentioned benefits to using inline SVG in case you wanted some more info: https://viget.com/extend/getting-started-with-inline-svg 这是一篇文章,阐述了在需要更多信息的情况下使用内嵌SVG的一些上述好处: https : //viget.com/extend/getting-started-with-inline-svg
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.