javascript max viewport height after orientation change Android & iOS

前端 未结 3 1724
遇见更好的自我
遇见更好的自我 2021-01-30 18:43

The Goal:

To find the max viewport height of a device including the space of the address bar so that we can dynamically resize the min-body and push our c

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-30 19:19

    This is a simple solution that will append the browsers width and height to the document body on load and window resize.

    jQuery.event.add(window, "load", resize);
    jQuery.event.add(window, "resize", resize);
    
      function resize() 
        {
          var h = jQuery(window).height();
          var w = jQuery(window).width();
          jQuery("body").css({"width": w, "height": h});
        }
    

提交回复
热议问题