SVG elements in Chrome not displayed

前端 未结 3 1109
既然无缘
既然无缘 2020-12-17 00:17

Chrome seems not to display elements in inline svg. Here is an example (code below or view it at http://www.bobwyttenbach.com/chromeuse.html):

相关标签:
3条回答
  • 2020-12-17 01:04

    I spent a long time debugging inline svg use elements not showing up. The chrome bug discussed by BobW seems fixed at this time. To eliminate the same issue caused by something else entirely, try commenting out the <base href="somethingsomethingsomething" /> tag from your HTML.

    Of course, this will likely break every relative link on your site, but the <use> elements now show up. One step forward, half a step back :)

    Related info here: Using base tag on a page that contains SVG marker elements fails to render marker

    0 讨论(0)
  • 2020-12-17 01:17

    Don't know if this question is still relevant, but I've met such a case recently and I pretty sure that somebody else will meet the case (especially those who tries to make use of SVG sprites for the first time).

    In my case I've joined 16 SVG icons in one sprite manually into sprite.svg, and in this file I've omitted important meta information:

    <?xml version="1.0" encoding="utf-8"?>
    <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> 
    

    I had no first line at all, and all I had on the second line was an opening <svg> tag with no meta attributes (xmlns and xmlns:xlink). As soon as I brought back all this omitted meta information, my graphics from sprite.svg started to display properly.

    Hope it helps someone.

    0 讨论(0)
  • 2020-12-17 01:19

    Ok so I deleted my last post as I incorrectly tried to figure out why the use element was working for me and not for you. What I can say is that I am using a modified version of this source, https://code.google.com/p/svg-edit/ , so in short, my answer is to walk through and see how they do it. I believe its demonstrated when you insert an image from their library.

    0 讨论(0)
提交回复
热议问题