0

i want orientation to be landscape, when my website is open in mobile and it must locks on landscape.

i tried some code as below, but it is not working as desired

function rotate(degrees) {
    $('body').css({
        '-webkit-transform': 'rotate(' + degrees + 'deg)',
        '-moz-transform': 'rotate(' + degrees + 'deg)',
        '-ms-transform': 'rotate(' + degrees + 'deg)',
        'transform': 'rotate(' + degrees + 'deg)'
    });
};
$(window).on("orientationchange", function(event) {
    if (window.orientation == 0) {} else {
        rotate(-90);
    }
});
$(window).orientationchange();
parth
  • 1,803
  • 2
  • 19
  • 27

1 Answers1

0

check this, already answered a similar question

forcing web-site to show in landscape mode only

I'd prefer to use CSS and CSS3 media queries rather than the JavaScript for such case.

Community
  • 1
  • 1
Sahan Perera
  • 194
  • 2
  • 5
  • 17