How can I limit or clip text in SVG?

前端 未结 5 1687
傲寒
傲寒 2021-02-06 23:36

I have done a table in SVG, and I want to fill it with data dynamically. That means that I don\'t know how much space the text takes, and I want to clip or hide the overlapping

5条回答
  •  时光取名叫无心
    2021-02-07 00:08

    If for some reason you don't want to use clipping, you can also use a nested SVG tag:

    
      
        Your text
      
    
    

    This way, your text will be cut off when it's outside the nested SVG viewport. Note that the x and y of the text tag refer to the coordinate system of the nested SVG, and correspond to 10 in the coordinate system of the outer SVG.

提交回复
热议问题