屏幕旋转的事件和样式

屏幕旋转的事件和样式

1.事件
    window.orientation,取值:正负90表示横屏模式、0和180表现为竖屏模式;
    window.onorientationchange = function(){
            switch(window.orientation){
                case -90:
                case 90:
                alert("横屏:" + window.orientation);
                case 0:
                case 180:
                alert("竖屏:" + window.orientation);
                break;
            }
    } 
2.样式
    //竖屏时使用的样式
    @media all and (orientation:portrait) {
        .css{}
    }

    //横屏时使用的样式
    @media all and (orientation:landscape) {
        .css{}
    }

posted @ 2015-11-25 15:47  Shimily  阅读(153)  评论(0编辑  收藏  举报