HTML中的连接:
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 18.0.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="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 474.986 474.986" style="enable-background:new 0 0 474.986 474.986;" xml:space="preserve">
<path id="XMLID_3_" d="M440.904,356.937l-15.139-80.104c-0.632-3.32-2.842-6.123-5.93-7.501c-3.081-1.386-6.647-1.163-9.542,0.577
l-69.815,42.086c-4.09,2.464-5.954,7.408-4.514,11.952c1.434,4.552,5.799,7.515,10.559,7.184l27.269-1.902
c-26.037,34.993-65.227,49.355-110.178,53.036V153.103h22.449c3.62,2.695,8.07,4.343,12.929,4.343
c12.021,0,21.771-9.742,21.771-21.764c0-12.029-9.75-21.771-21.771-21.771c-4.867,0-9.318,1.656-12.938,4.351h-22.441V86.789
c12.776-8.494,21.231-22.987,21.231-39.436C284.845,21.247,263.6,0,237.493,0c-26.107,0-47.354,21.247-47.354,47.353
c0,16.449,8.456,30.942,21.231,39.436v31.474h-22.44c-3.62-2.695-8.07-4.351-12.937-4.351c-12.021,0-21.771,9.742-21.771,21.771
c0,12.021,9.75,21.764,21.771,21.764c4.859,0,9.309-1.648,12.929-4.343h22.448v229.162c-44.95-3.681-84.14-18.043-110.176-53.036
l27.269,1.902c4.759,0.331,9.125-2.632,10.558-7.184c1.44-4.543-0.423-9.488-4.513-11.952l-69.816-42.086
c-2.896-1.74-6.461-1.963-9.542-0.577c-3.088,1.378-5.298,4.181-5.93,7.501l-15.14,80.104c-0.886,4.689,1.555,9.372,5.906,11.327
c4.351,1.965,9.472,0.686,12.399-3.088l16.287-21.008c31.843,51.565,81.914,94.736,139.664,105.942l21.854,21.854
c4.036,4.028,10.565,4.028,14.594,0l21.854-21.854c57.75-11.198,107.828-54.377,139.672-105.942l16.287,21.008
c2.927,3.774,8.048,5.053,12.398,3.088C439.349,366.309,441.79,361.626,440.904,356.937z M237.493,34.839
c6.9,0,12.513,5.614,12.513,12.514c0,6.9-5.613,12.514-12.513,12.514c-6.9,0-12.515-5.614-12.515-12.514
C224.979,40.453,230.593,34.839,237.493,34.839z"/>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>
UPD 在片段中,它显示在站点的此处,但是如果将其保存到单独的文件*.svg
中,则在浏览器中启动时会出错。
首先,从 SVG 文件中删除第一行,它不需要并且会干扰打开 SVG 文件。
现在,文件被打开:
此外,您可以简单地将这段代码复制到您的页面中,这就是将 SVG 添加到 HTML 的所谓内联方式。在你学会如何自信地使用 SVG 之前,最好这样做,一切都会为你工作。
第二种添加位于服务器上单独文件夹中的 SVG 文件的方法比较复杂,需要一些知识
首先将 SVG 文件添加到 HTML
ID
然后才从这个精灵调用图标:此方法适用于所有浏览器
<img>
,添加 SVG 的方式与添加位图的方式相同,因此图标样式和交互性将不起作用。您可以在此处阅读更多详细信息