开发者

How to get width in specified units (pt, ex, etc.)

In m开发者_如何学Cy script, i need to get width of an element in "ex" units (font width)

Is there any way to do this using JavaScript, jQuery ?


Not directly. jQuery uses the offsetWidth and offsetHeight properties, which only return integer values. If the exact width you're looking for is specified in the stylesheet, you can probably use element.css('width') and get the intended result, but, otherwise, you'll have to either do some serious trickery to convert, or just deal with using pixels instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜