为什么jquery .height()在chrome上得到不同的结果?

这是chrome显示div的宽度和高度的方式:

这是正确的,实际上高度是1466.但是,如果我这样做:

$(document).ready(function () {
    console.log($('#container-altezza-fisso').height());
});

它打印1418.它没有任何填充/边距.为什么?我该如何解决

解决方法

那是因为在Domready上有些图像没有完全加载.你应该在窗口加载时调用高度.
$(window).load(function(){
    console.log($('#container-altezza-fisso').height());
})

你也可以使用outerHeight:

Get the current computed height for the first element in the set of matched elements,including padding,border,and optionally margin. Returns an integer (without “px”) representation of the value or null if called on an empty set of elements.

console.log($('#container-altezza-fisso').outerHeight());

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: <span id=&quot...
jQuery 添加水印 <script src="../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...