是否可以使用javascript以em为单位获取窗口的宽度? [英] Is it possible to get the width of the window in em units using javascript?
本文介绍了是否可以使用javascript以em为单位获取窗口的宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一种可靠的方法来使用javascript以em为单位获取窗口的宽度。我很惊讶地看到jQuery只返回像素测量结果。任何帮助都表示赞赏。
I'm looking for a reliable way to get the width of the window in em units using javascript. I was surprised to see that jQuery will only return a result in pixel measurements. Any help is appreciated.
推荐答案
这似乎有效:
$(window).width() / parseFloat($("body").css("font-size"));
这篇关于是否可以使用javascript以em为单位获取窗口的宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文