SVG Scaling Text to fit container

前端 未结 4 839
迷失自我
迷失自我 2020-12-02 17:06

This is likely a very simple question, but how do I get text in SVG to stretch to fit its container?

I don\'t care if it looks ugly from being stretched too long or

4条回答
  •  情深已故
    2020-12-02 17:32

    Here is what I have come up with... Its similar to what other people have posted, but I think it resizes and scales nicely. This code will add spacing to any text roughly between 10-25 characters to make it fill the entire width of its parent. If you need longer or shorter text, just adjust the viewBox width and textLength attributes.

    
    
        Some Unknown Text that is resizing
    
    

提交回复
热议问题