Device: force orientation landscape (Phonegap JQueryMobile)

人走茶凉 提交于 2019-12-12 13:33:50

问题


I have been searching for days for a way to always display just one particular jquery mobile page div in landscape mode.

Anyone any examples or ideas that could help, I would really appreciate it.

function forceLandscape() {
    console.log('Starting: forceLandscape ');
    console.log('----------------------------------------------------');


    //    var orientation = window.orientation;
    //    var new_orientation = 0;
    //    switch (orientation) {
    //        case 90:
    //            break;
    //        case -90:
    //            new_orientation = 180
    //            $('body').css({ ".ui-mobile,.ui-mobile .ui-page{min-height:300px} -webkit-transform": "rotate(" + new_orientation + "deg);" });
    //            break;
    //        case 180:
    //            new_orientation = 270;
    //            $('body').css({ ".ui-mobile,.ui-mobile .ui-page{min-height:300px} -webkit-transform": "rotate(" + new_orientation + "deg);" });
    //            break;
    //        case 0:
    //            new_orientation = 90;
    //            $('body').css({ ".ui-mobile,.ui-mobile .ui-page{min-height:300px} -webkit-transform": "rotate(" + new_orientation + "deg);" });
    //            break;
    //        default:
    //            $('body').css({ ".ui-mobile,.ui-mobile .ui-page{min-height:300px} -webkit-transform": "rotate(" + new_orientation + "deg);" });
    //    }  


    console.log('----------------------------------------------------');
    console.log('Completed: forceLandscape ');
}

回答1:


This isn't recommended but you could do:

$('body').css({
   "-webkit-transform": "rotate(90deg)"
   put other browsers here
}); 

or just in css

#page {
transform:rotate(90deg);
-ms-transform:rotate(90deg); /* IE 9 */
-moz-transform:rotate(90deg); /* Firefox */
-webkit-transform:rotate(90deg); /* Safari and Chrome */
-o-transform:rotate(90deg); /* Opera */
}


来源:https://stackoverflow.com/questions/9836580/device-force-orientation-landscape-phonegap-jquerymobile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!