如何检索HTML元素的实际宽度和高度?

為{幸葍}努か 提交于 2020-10-07 04:27:01

问题:

Suppose that I have a <div> that I wish to center in the browser's display (viewport). 假设我有一个<div> ,希望在浏览器的显示(视口)中居中。 To do so, I need to calculate the width and height of the <div> element. 为此,我需要计算<div>元素的宽度和高度。

What should I use? 我应该使用什么? Please include information on browser compatibility. 请提供有关浏览器兼容性的信息。


解决方案:

参考一: https://stackoom.com/question/1EXy/如何检索HTML元素的实际宽度和高度
参考二: https://oldbug.net/q/1EXy/How-do-I-retrieve-an-HTML-element-s-actual-width-and-height
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!