[英]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.