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

前端 未结 3 442
轻奢々
轻奢々 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:31

    try this

    http://blog.mastykarz.nl/measuring-the-length-of-a-string-in-pixels-using-javascript/

提交回复
热议问题