outerHeight(true) gives wrong value

前端 未结 10 1577
旧时难觅i
旧时难觅i 2021-01-07 18:21

I want the height of a container element, including margins and paddings.

When I hover over the element in Chrome development tool, I get the value that I\'m lookin

10条回答
  •  长情又很酷
    2021-01-07 18:38

    I've run into same problem.

    Firefox outerheight via console.log: 430 Chrome outerheight via console.log: 477

    Real outerheight (firebug layout): 820

    After opening Firebug or removing statusbar it sets correct value (820) in console.log (and hence the code works as it should).

    The issue was due to images. Even though you are running it on document ready, not all images might be loaded yet, and therefore the calculations are wrong.

    I am using desandro's plugin and it has fixed my issue. https://github.com/desandro/imagesloaded

提交回复
热议问题