'Android portrait keyboard pop up changing my orientation to landscape

So i have a bug on andriod devices where the keyboard pops up during portrait mode and the background changes (taking the landscape media queries)

I am currently testing on 360x640 devices (HTC One, Samsung S4 etc)

I read here and other webistes to use (max-aspect-ratio: 13/9) for portrait and (min-aspect-ratio: 13/9) for landscape. However it is not working. This is my media queries for the portrait.

@media only screen

and (min-device-width:360px)

and (max-device-width:640px)

and (max-aspect-ratio: 13/9)

Someone please help me :)



Solution 1:[1]

Using

@media screen and (min-aspect-ratio: 13/9) {

instead of

@media (orientation: landscape) {

seems to help. You just gott figure out a good aspect ratio that will cover most devices.

Source: https://web.archive.org/web/20160509220835/http://blog.abouthalf.com/development/orientation-media-query-challenges-in-android-browsers/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 StudioWorks