Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/185.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript getBoundingClientRect()值在移动设备上更大(2倍)_Javascript_Android_Mobile_Device_Offset - Fatal编程技术网

Javascript getBoundingClientRect()值在移动设备上更大(2倍)

Javascript getBoundingClientRect()值在移动设备上更大(2倍),javascript,android,mobile,device,offset,Javascript,Android,Mobile,Device,Offset,Javascript的getBoundingClientRect()值在我的移动设备上要大两倍。 如果在桌面浏览器中运行下面的代码,则是正确的。 然后在响应性开发工具中以固定的设备高度运行代码。 在chrome:640px高度中,我向下滚动到底部,重新加载它,看到-1936px。 如何在移动设备上获得正确的640+-10px值? 对于高分辨率显示器或任何其他因素,是否存在比率 <html> <body> <div id="output" style="wid

Javascript的
getBoundingClientRect()
值在我的移动设备上要大两倍。 如果在桌面浏览器中运行下面的代码,则是正确的。 然后在响应性开发工具中以固定的设备高度运行代码。 在chrome:640px高度中,我向下滚动到底部,重新加载它,看到-1936px。 如何在移动设备上获得正确的640+-10px值? 对于高分辨率显示器或任何其他因素,是否存在比率

<html>
<body>
    <div id="output" style="width:100%; height:100%; background-color:green; font-size:30pt;"><script>document.write(document.getElementById('output').getBoundingClientRect().top);</script></div>
    <div style="height:100%; width:100%; font-size:30pt;">
    <script>document.write(document.getElementById('output').getBoundingClientRect().top);</script></div>
</body>
</html>

document.write(document.getElementById('output').getBoundingClientRect().top);
document.write(document.getElementById('output').getBoundingClientRect().top);
在我的HTCM9上,值正好是2倍大。。。 甚至Jquery函数和其他解决方案似乎也不起作用


我无法复制您的结果。你能发布一个代码段吗(使用堆栈代码段工具)?不适用于代码段,但我制作了一个图像…我无法复制你的结果。你能发布一个代码段吗(使用堆栈代码段工具)?不适用于代码段,但我制作了一个图像。。。