I am trying to import a style based off a media query but the import is not being triggered If i put styles directly in the media query they are rendered to the page.
<
I had the same problem and after searching without finding a good solution, I ended up moving the media queries to the imported css instead. And in fact all the style sheets are downloaded even if they are not applied anyway (see CSS media queries).
Then what's the point of having separate files? For me, it keeps things organized. Using your example:
@import url(min480.css); /* min-width: 480px */
@import url(min600.css); /* min-width: 600px */
Then on the min600.css:
/* min600.css */
@media only screen and (min-width: 600px) {
header {
text-align: left;
}
body {
background: green;
}
}