Skip to content

Instantly share code, notes, and snippets.

@alexmahan
Last active May 3, 2018 13:28
Show Gist options
  • Save alexmahan/ccb93bea58d0e81e739e to your computer and use it in GitHub Desktop.
Save alexmahan/ccb93bea58d0e81e739e to your computer and use it in GitHub Desktop.
Landscape orientation media query mixin for Android. When the keyboard pops up in portrait mode, the window resize event is triggered and it thinks that the device is in landscape mode. This behavior is stupid (http://blog.abouthalf.com/development/orientation-media-query-challenges-in-android-browsers). This fixes that, mostly.
@mixin mobile-landscape() {
@media only screen and (max-height: 420px) and (max-width: 767px) and (orientation: landscape) and (min-aspect-ratio: 13/9) {
@content;
}
}
@alexmahan
Copy link
Author

The max-height and max-width properities aren't required, obviously. Just needed them for my specific scenario.

@Shankar1598
Copy link

How to apply this using css?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment