简体   繁体   中英

SVG use not working in Safari

Im using this svg tag in my html file. It works perfectly in Chrome, but in safari the icon doesn't appear

<svg width="25" height="23" viewBox="0 0 25 23">
       <use href="./icons.svg#helemet"></use>
 </svg>

any know why?

Safari doesn't support href yet, you need to use xlink:href instead.

href is a new feature of the upcoming SVG 2 specification. xlink:href is the SVG 1.1 version.

Chrome, Firefox and Edge support both xlink:href and href.

Here is an update from the future 2019. Just add xlink:

<svg role="img">
    <use xlink:href="/path/to/svg#id"></use>
</svg>

Works with IOS 12

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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