的像素宽度在跨度和iframe身上 [英] Width in pixel of   in span and iframe body

查看:95
本文介绍了 的像素宽度在跨度和iframe身上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道& nbsp; 的像素宽度,以及它是否取决于字体大小。此外,这是不同的页面不同元素?



此外,& nbsp; 不同于一个普通的

解决方案

尽管Maccath的回答是遵循正确的建议,直接回答你的问题:是的,你可以通过使用一些获得宽度 javascript:

例如,给定:

 < span id = NBSP >&安培; NBSP;< /跨度> 

可以使用jQuery检索宽度:

  $('#nbsp')。width()

jQuery在渲染时返回< span> 的宽度,所以它占字体大小等。现在你知道如何去做,吨。


I need to know the width of a &nbsp; in pixels, and whether it depends on the font-size. Also, does this vary across different elements in the page?

Also, is the &nbsp; 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">&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.

这篇关于&nbsp;的像素宽度在跨度和iframe身上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆