23

At the moment, i'm working on my site. The mobile version is almost done. But if I rotate my screen (smartphone for example) in landscape, it looks horrific. I tried to change it with queries but the result isn't quite nice. Is there a way to lock orientation so that it always stays in portrait-mode?

Edit:

I thought maybe I could do something with the height and the width. So that if the width of the screen is larger then the height, the body should rotate 90 degrees.

Soccerlife
  • 671
  • 3
  • 9
  • 20

1 Answers1

29

You need to add the following meta tag to your page header like so:

<meta http-equiv="ScreenOrientation" content="autoRotate:disabled">

Or you can have separate CSS files for landscape and portrait mode like so:

<link rel="stylesheet" type="text/css" href="css/landscape.css" media="screen and (orientation: landscape)">
<link rel="stylesheet" type="text/css" href="css/portrait.css" media="screen and (orientation: portrait)">
Shakti Phartiyal
  • 6,156
  • 3
  • 25
  • 46