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;
}
}
It works fine, try to resize your window and you will see the colors changing As I can see in my main window on my screen (1920x1080) the CSS rule
body {
background: url("../img/noisy_grid.png");
}
Located in style.css , line 37-38 fires first, that's why you can't see the orange color. Try re arrange your css rules
true statement
@import ('filename.css') mediaType and (feature: value);
example:
@import (responsive.css) screen and (min-width: 320px) and (max-width: 480px);
notice:
if use @import for CSS file, this file should not attachment in <link>
tag. otherwise dose not work Styles.
Here is the solution:
/* Everything 700px and lower */
@import url("./700.css") only screen and (max-width: 700px);
try that kind of code
@import url("/inc/Styles/full.css") (min-width: 940px);
Did you use like this?
You can write:
@import url('path.css') (screen and min/max-width: 600px);
You can add path as you use @import
or like:
@import url(style.css) (screen and min-width:600px);