jQuery returning different heights for the same objects in WebKit (chrome) and Firefox

后端 未结 4 1843
野性不改
野性不改 2021-02-02 17:45

Im perplexed by this one.

jQuery.height() is coming back with different values in Firefox and Chrome. Measuring the pixels on-screen indicates that of the two, Chrome ap

4条回答
  •  花落未央
    2021-02-02 18:48

    I had the similar problem, that seems to be a bug although i am not 100% sure. If for example, a certain element has padding, the innerHeight() didn't show the same result in Webkit and Firefox. As temporary fix, I used both innerHeight() as well as height() to get the right height for that element.

    Similarly, I wasn't able to use the height() to show the same across browsers (IE and others). I used something like this that worked across browsers:

    $("#element").css('height', '100');
    

    See also innerHeight() and outerHeight() when you want to include padding / borders / margins.

提交回复
热议问题