What's the most reliable way to detect a device's orientation using CSS @media queries?
I tried these:
@media screen and (orientation: portrait)
@media screen and (orientation: landscape)
but they don't work in all cases. On some Android devices, showing the keyboard in portrait mode can make it use the "orientation: landscape" query, since the aspect ratio is more than 1/1.
I've seen suggestions to use this instead:
@media screen and (max-aspect-ratio: 13/9) // portrait
@media screen and (min-aspect-ratio: 13/9) // landscape
But these doesn't work on PhoneGap on the iPad; you need a ratio of something more like 12/9. And I'm a little concerned about targeting such a specific ratio, since there might be devices whose landscape mode is less than that ratio.
So is there a more reliable way to test this? (I'm only looking for a CSS @media query, not a JavaScript solution.)