Add ellipses to overflowing text in SVG?

前端 未结 6 1056
广开言路
广开言路 2020-11-30 03:20

I\'m using D3.js. I\'d like to find an SVG equivalent to this CSS class, which adds ellipses if text flows out of its containing div:



        
6条回答
  •  天命终不由人
    2020-11-30 03:43

    I am not aware of an equivalent CSS class for SVG, but you can use foreignObject to embed HTML in SVG. This gives you access to this functionality and is more flexible in general (e.g. you can do automatic line breaking easily).

    See here for a complete example.

提交回复
热议问题