开发者

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

开发者 https://www.devze.com 2023-01-06 00:07 出处:网络
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 offsetHe

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

精彩评论

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