What is the best method of re-rendering a web page on orientation change?

后端 未结 8 787
臣服心动
臣服心动 2020-11-28 06:43

I have a fluid CSS layout which is rendering badly on an iphone when I change the orientation. (It looks fine when it is refreshed).

I am using the code below to ref

8条回答
  •  悲哀的现实
    2020-11-28 07:28

    Try something like this:

    $(function(){
    
        changeOrientation(window.orientation == 0 ? "portrait" : "landscape");
    
        $('body').bind('orientationchange',function(event){
            changeOrientation(event.orientation)
        });
    
        function changeOrientation(ori){
            $("#orientation").removeClass('portrait landscape');
            $("#orientation").addClass(ori);
        }     
    });
    

提交回复
热议问题