I am trying to create a background color that changes based on the orientation of the device. Here is the code I have been using:
<meta name="viewport" content="width=device-width">
...
@media all and (max-device-width: 360px) {
div { background-color: green; } }
@media all and (min-device-width: 361px) {
div { background-color: blue; } }
However, this code does not seem to be effective. Surprisingly, when I replace max-device-width
and min-device-width
with max-width
and min-width
, it works perfectly fine.
What could be the reason behind the failure of using max-device-width
and min-device-width
in the code?