Do I use , <>, >

后端 未结 15 1888
借酒劲吻你
借酒劲吻你 2020-11-22 06:10

Should I use , , or for loading SVG files into a page in a way similar to loading a jpg
15条回答
  •  悲&欢浪女
    2020-11-22 06:51

    If you need your SVGs to be fully styleable with CSS they have to be inline in the DOM. This can be achieved through SVG injection, which uses Javascript to replace a HTML element (usually an element) with the contents of an SVG file after the page has loaded.

    Here is a minimal example using SVGInject:

    
    
      
    
    
      
    
    
    

    After the image is loaded the onload="SVGInject(this) will trigger the injection and the element will be replaced by the contents of the file provided in the src attribute. This works with all browsers that support SVG.

    Disclaimer: I am the co-author of SVGInject

提交回复
热议问题