Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent landscape orientation Mobile-website [duplicate]

Tags:

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.

like image 376
Soccerlife Avatar asked Apr 26 '17 12:04

Soccerlife


People also ask

How do I turn off landscape mode on my website?

In order to disable the landscape mode you need to add the following meta tag to your page header like so: Note: Please paste it at the top of your header. You can use the plugin call insert headers and footers to do so.

How do I stop Safari from turning sideways?

Swipe down from the top-right corner of your screen to open Control Center. Tap the Portrait Orientation Lock button to make sure that it's off.

How do I restrict orientation on Android?

Add android:screenOrientation="portrait" to the activity you want to disable landscape mode in.

How do you lock orientation on iPhone?

On iPhone X or later, swipe down from the top right side of your iPhone screen. If you have an iPhone SE (2nd gen) or an iPhone 8 or earlier, swipe up from the bottom of your screen (3 finger swipe up for VoiceOver users), to open Control Center. Select the Portrait Orientation Lock icon.


1 Answers

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)">
like image 125
Shakti Phartiyal Avatar answered Nov 02 '22 02:11

Shakti Phartiyal