jQuery .height() problem with chrome

后端 未结 6 1102
离开以前
离开以前 2020-12-10 02:37

I\'ve been using jQuery Height function. But there was a problem in getting the correct height of my div element. This div element\'s height is set

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-10 02:40

    I had the same issue with bootstrap dropdown menu that elements had to be height normalized. For some menus (not all), jquery did not return the right height, resulting in bad normalization. It was because dropdown menus were hidden during the normalization. It seems that CHROME and FIREFOX does not compute the height correctly when the element is hidden. IE seems to work better in this case.

    To solve the issue, I have add (then remove) the bootstrap class "open" to all menus, in order to make them visible during the normalization:

        $(window).on( "load resize orientationchange", function() {
            $(".dropdown").addClass("open");
            normalize_all();
            $(".dropdown").removeClass("open");
        });
    

提交回复
热议问题