I'm using both the screen width and screen height to detect the difference between mobile and desktops and then detect high resolution desktops vs. low resolution desktops.
I have some JavaScript that I use to load different CSS files. It looks like this:
JavaScript
<script>
if (screen.width > 800) {
if (screen.height < 900) {
document.write('<link href="/LowRes.css" type="text/css" />');
} else {
document.write('<link href="/HiRes.css" type="text/css" />');
}
} else {
document.write('<meta name="viewport" content="width=device-width,initial-scale=1">');
document.write('<link href="/Mobile.css" type="text/css" />');
}
</script>
I want to change that and use media queries, and this is what I have:
CSS
<link media="screen and (min-device-width: 801px) and (min-device-width: 801px)" href="low.css" rel="stylesheet" />
<link media="screen and (min-device-height: 901px)" href="hi.css" rel="stylesheet" />
<link media="screen and (max-device-width: 800px) and (orientation : portrait), screen and (max-device-height: 800px) and (orientation : landscape)" href="mobile.css" rel="stylesheet" />
This allows for the mobile stylesheet to be downloaded regardless of the orientation. However, the desktop stylesheet is always set to hi-res even if it's actually low-res.
As you can see, I've got the desktop mode on height 800px, the media query is set for min-device-height:901px
and yet it's downloading the hi-res stylesheet. Why is that?