简体   繁体   English

在img标签下使用svg文件

[英]Using svg file under img Tag

I am using ASP.NET mvc4 application, where .svg files will be placed under /content/Images folder. 我正在使用ASP.NET mvc4应用程序,其中.svg文件将放置在/content/Images文件夹下。

Under <img> tag i Am trying to use .svg file as src. <img>标记下,我正在尝试使用.svg文件作为src. But this seems not working. 但这似乎不起作用。 But inline svg works fine. 但是内嵌svg可以正常工作。 But my requirement demands it to be used under <img> tag. 但我的要求要求它在<img>标签下使用。 I have used proper MIME type also. 我也使用了正确的MIME类型。

<img src=http://localhost:62987/Content/Images/simplest.svg />

Its probably because you are missing the inverted commas around the src attribute's path. 这可能是因为您缺少src属性路径周围的反逗号。

This syntax should work fine. 此语法应该可以正常工作。

<img src="http://localhost:62987/Content/Images/simplest.svg" />

Check this working JSFiddle to demonstrate that the above mentioned method just works fine. 检查此工作的JSFiddle,以证明上述方法可以正常工作。

Also check that your web server is serving your SVG files with the correct mime type. 还要检查您的Web服务器是否以正确的mime类型提供SVG文件。 It should be image/svg+xml . 它应该是image/svg+xml An easy way to check is to look under the "Net" tab in your web browser development tools. 一种简单的检查方法是在网络浏览器开发工具的“网络”标签下查看。

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

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