However, I have notice that there is a certain width of the window where the styles from both media queries seem to be mixed together. (It definitely isn't the case that no query is applied.)
Correct; instead, both of them are being applied, and that's when the width of the viewport exactly equals 34 ems. What happens then is that the cascade applies as usual. See my answer to the following question for an explanation:
What are the rules for CSS media query overlap?
The easiest way to handle this for two ranges of screen sizes is to utilize the cascade, but differently from what you have: by writing your rules generally for one screen size, and only including a media query for the other screen size as shown in dwreck08's answer.
Otherwise, if you want exactly one rule to be applied at a time without relying on the cascade to override your styles, use either min-width
or max-width
only, and negate it in the other rule with the not
keyword. As an example, you can have either this:
@media screen and (max-width: 34em) {} /* Smaller screen sizes */
@media not screen and (max-width: 34em) {} /* Larger screen sizes */
Or this:
@media not screen and (min-width: 34em) {} /* Smaller screen sizes */
@media screen and (min-width: 34em) {} /* Larger screen sizes */
The ordering does not matter because not
makes these rules mutually exclusive — at least, in the browsers that understand the keyword, which as far as I know is all of them that support media queries anyway.
My answer to this question, which is a follow-up to the one linked above, offers another explanation:
How can I avoid media query overlap?