How can you measure the space that a text will take in Javascript?

前端 未结 3 468
轻奢々
轻奢々 2020-12-30 15:13

In Javascript, I have a certain string, and I would like to somehow measure how much space (in pixels) it will take within a certain element.

Basically what I have i

3条回答
  •  天命终不由人
    2020-12-30 15:41

    This is easy using a JavaScript framework. I'm using Prototype in this example.

    hello this is sample text
    
    
    

提交回复
热议问题