的像素宽度在跨度和iframe身上 [英] Width in pixel of   in span and iframe body
问题描述
我需要知道& nbsp;
的像素宽度,以及它是否取决于字体大小。此外,这是不同的页面不同元素?
此外,& nbsp;
不同于一个普通的
?
尽管Maccath的回答是遵循正确的建议,直接回答你的问题:是的,你可以通过使用一些获得宽度 javascript:
例如,给定:
< span id = NBSP >&安培; NBSP;< /跨度>
可以使用jQuery检索宽度:
$('#nbsp')。width()
jQuery在渲染时返回< span>
的宽度,所以它占字体大小等。现在你知道如何去做,吨。
I need to know the width of a
in pixels, and whether it depends on the font-size. Also, does this vary across different elements in the page?
Also, is the
different from a regular ?
Although Maccath's answer is the correct advice to follow, to answer your question directly: Yes, you can actually get the width quite simply by using some javascript:
For instance, given:
<span id="nbsp"> </span>
The width can be retrieved using jQuery:
$('#nbsp').width()
jQuery returns the width of the <span>
as it is rendered, so it accounts for font-size, etc. Now that you know how to do it, don't.
这篇关于 的像素宽度在跨度和iframe身上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!