Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/433.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.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在Windows/IE11中的范围元素上不正确_Javascript_Internet Explorer 11_Getboundingclientrect - Fatal编程技术网

Javascript getBoundingClientRect在Windows/IE11中的范围元素上不正确

Javascript getBoundingClientRect在Windows/IE11中的范围元素上不正确,javascript,internet-explorer-11,getboundingclientrect,Javascript,Internet Explorer 11,Getboundingclientrect,在IE11中使用range对象获取BoundingClientRect时,它会报告错误的数字。它报告的高度为128,而实际高度为74。它将顶部偏移报告为8,而实际顶部偏移为35 这是已知的bug吗?在WindowsIE11中,有没有一种方法可以获得选择的准确数字 var div=document.querySelectorAll('div')[0]; var t=div.childNodes[0]; var range=document.createRange(); 范围。设置开始(t,0)

在IE11中使用range对象获取BoundingClientRect时,它会报告错误的数字。它报告的高度为128,而实际高度为74。它将顶部偏移报告为8,而实际顶部偏移为35

这是已知的bug吗?在WindowsIE11中,有没有一种方法可以获得选择的准确数字

var div=document.querySelectorAll('div')[0];
var t=div.childNodes[0];
var range=document.createRange();
范围。设置开始(t,0)
范围设置结束(t,1)
console.log(range.getBoundingClientRect())
div.text{
字体大小:64px;
线高:1米;
}
T
编辑:

对我来说,Win 7 64位IE11.0.9600运行您的代码段控制台上显示:

[object ClientRect]{bottom: 72, constructor: ClientRect {...}, height: 64, left: 8, right: 47.090000152...", top: 8, width: 39.090000152..."}
大致匹配FF 47.0.1的值:

DOMRect { x: 8, y: 3.3333282470703125, width: 38.5, height: 73.33334350585938, top: 3.3333282470703125, right: 46.5, bottom: 76.66667175292969, left: 8 }

能否尝试定义字体系列并重试。另外,请确保浏览器缩放为100%。我很恼火,当我发布这篇文章时,我得到的数字与我现在在同一个windows虚拟环境中得到的数字大不相同。我不确定是什么改变了,但我现在看到的和你看到的一样。