[英]Why does the same code using getClientRects() produce different results?
I have the code snippet below. 我有下面的代码片段。 If you press "Run code snippet" then you will see the following
如果按“运行代码段”,则会看到以下内容
1 - p.getClientRects().length
1 - p.getClientRects()。length
2 - span.getClientRects().length
2 - span.getClientRects()。length
But if you press "Expand snippet" at first, and then "Run code snippet" then you will see a bit different result: 但是如果你先按“扩展片段”,然后按“运行代码片段”,那么你会看到一些不同的结果:
1 - p.getClientRects().length
1 - p.getClientRects()。length
1 - span.getClientRects().length
1 - span.getClientRects()。length
I just want to understand Element.getClientRects() method. 我只想了解Element.getClientRects()方法。 But this situation crashes me.
但是这种情况让我崩溃了。 Could you explain why it produces different results?
你能解释为什么会产生不同的结果吗?
My browser is: Chrome Version 67.0.3396.99 (Official Build) (64-bit) 我的浏览器是:Chrome版本67.0.3396.99(官方版本)(64位)
var p = document.querySelector('p'); var span = document.querySelector('span'); console.log(p.getClientRects().length, "- p.getClientRects().length"); console.log(span.getClientRects().length, "- span.getClientRects().length");
p { border: 1px solid green; } span { border: 1px solid red; }
<p> This is a paragraph with <span>Span Element having a looooooooooooooooooooooo nnnnnnnnnnnnnnnnnnnn ggggggggggggggggg text</span> </p>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.