繁体   English   中英

这两个显示同一元素的高度和偏移高度的警报为什么不会显示相同的数字?

[英]How come these two alerts showing the height and offsetheight of the same element don't display the same number?

警报如下:

alert(document.getElementById("col_st_scroll").offsetHeight);
alert(document.getElementById("col_st_scroll").style.height);

现在,col_st_scroll元素在Web浏览器中完全可见,这是否不意味着offsetHeight和style.height应该返回相同的值?

问题解决了。 在单击第一个警报时单击确定所需的时间,该元素已由其他功能调整大小。

这是来自MDN的

通常,元素的offsetHeight是一个度量,其中包括元素边框,元素垂直填充,元素水平滚动条(如果存在,如果呈现)和元素CSS高度。

style.height属性仅表示内容的高度(假设您使用的是“严格”渲染模式,而不是“怪癖”)。

暂无
暂无

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

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