How can i get default font size in pixels by using JavaScript or JQuery?

前端 未结 9 1460
Happy的楠姐
Happy的楠姐 2021-02-04 09:07

As you know em is a relative font measurement where one em is equal to the height of the letter \"M\" in the default font size. An advantage in using it is because you will be a

9条回答
  •  离开以前
    2021-02-04 09:59

    One trick I've seen/used in the past is to render some text (say 50 arbitrary characters, or Ms) and then measure the size of the rendered container and do the math to figure out the height and width of a single character. Is this what you're going for? You can do the rendering in the background so the user doesn't see it.

提交回复
热议问题