Can text be added to an SVG path?

前端 未结 1 1543
一向
一向 2021-01-06 01:30

Is it possible to add text to an svg path, I have created a svg triangle and would like to add a letter to the center of this but not sure if this is possible?

1条回答
  •  庸人自扰
    2021-01-06 02:15

    Yes. See section 10.13 of the SVG1.1 specification (titled "Text on a path") for information on using the textPath element.

    Summarized:

    1. Give your path an id attribute.
    2. Create My text here

    Here's an example straight from the spec:

    SVG Image with text following the curve of the path with ID

    
    
    
      
        
      
      Example toap01 - simple text on a path
    
      
      
        
          We go up, then we go down, then up again
        
      
    
    
    

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