简体   繁体   English

CONSOLE.LOG div 属性

[英]CONSOLE.LOG div attributes

So I have the following div.所以我有以下div。

On google chrome I can inspect the element and see the size of the div.在谷歌浏览器上,我可以检查元素并查看 div 的大小。 How can I capture the size of this div and store it as a variable?如何捕获此 div 的大小并将其存储为变量? I'm assuming this can dynamically change depending on the users platform.我假设这可以根据用户平台动态变化。

I need the current size of the div to create a ping pong type floating ball contained in the size of that div.我需要 div 的当前大小来创建包含在该 div 大小中的乒乓球类型的浮动球。

Sounds like you're looking for getBoundingClientRect , which gives you the bounding box values for any element in the DOM.听起来您正在寻找getBoundingClientRect ,它为您提供 DOM 中任何元素的边界框值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM