问题:
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
来源:oschina
链接:https://my.oschina.net/u/4438370/blog/4325980