Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.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/8/file/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
Jquery 非整数圆顶高度_Jquery_Css_Dhtml - Fatal编程技术网

Jquery 非整数圆顶高度

Jquery 非整数圆顶高度,jquery,css,dhtml,Jquery,Css,Dhtml,我有一张有行的桌子,需要计算出任何一行的高度 var height = $('table').find('tbody > tr').height(); console.log(height); 在我的特殊情况下,这会产生18。好的,我用它来计算一个可滚动div中的索引。这就是index=scrollTop/rowHeight,但有些不正确 经过进一步调查,我发现在本例中,IE9报告的高度实际上是18.4。使用该值进行计算 我不知道如何得到这个值。我尝试过的所有方法都使用jQuery、in

我有一张有行的桌子,需要计算出任何一行的高度

var height = $('table').find('tbody > tr').height();
console.log(height);
在我的特殊情况下,这会产生
18
。好的,我用它来计算一个可滚动div中的索引。这就是
index=scrollTop/rowHeight
,但有些不正确

经过进一步调查,我发现在本例中,IE9报告的高度实际上是
18.4
。使用该值进行计算

我不知道如何得到这个值。我尝试过的所有方法都使用jQuery、
innerHeight
outerHeight
(包括和不包括边距)和
height
。它们都返回
18
一个整数!?表格高度与行数之比是一个合理的近似值(
18.40625
),但该值会导致细微的舍入误差。我试过
round
floor
ceil
都没用

到目前为止,我实现这一点的唯一方法是将每行高度固定为某个整数值。但我真的想去掉它,我应该能够计算行高,这样它可以是任何值,只要它是常数

这个
18.4
是计算出的
行高
,将其设置为整数可以解决问题,但我不想处理设备像素。我不明白为什么没有办法获得开发人员工具显示的实际高度值(根据MSDN文档,它是
offsetHeight
,但该属性是一个整数,这是错误的)


我需要帮助。

这很痛苦,但我相信你应该能够通过窗口到达高度。getComputedStyle(elem,null)呼叫。如果您没有在标准模式下使用IE9,则需要转到IE专有的elem.currentStyle属性(其他浏览器自然会使用标准调用)。请记住,您需要将元素的填充和边框宽度添加到style.height值中,并且您需要对该值进行分析,因为它的末尾将返回“px”。

您是否有18.4像素的高度?@Shota-我相信是这样,这是检查过的值,并且是像素。我从来没有设置过线条高度,在我的例子中,默认为18.4像素。