Media queries cascade. That is to say, at 601px
your @media screen and (max-width: 601px)
media query would correctly take affect, but the @media screen and (max-width: 993px)
media query will also take affect, as 601px
is smaller than 993px
. Thus, the element has both media queries applied. And because your element still has the hide-medium
class at a 'small' width, it will still be hidden.
If you don't want this to happen, I'd recommend explicitly setting a min-width
on your middle media-query as well:
@media screen and (min-width: 994px) {
.hide-large {
display: none
}
}
@media screen and (max-width: 993px) and (min-width: 602px) {
.hide-medium {
display: none
}
}
@media screen and (max-width: 601px) {
.hide-small {
display: none
}
}
<div class="hide-medium hide-large">Test</div>
It's also important to note that media queries in the same stylesheet are applied top-to-bottom. If you have a 'lower down' media query that has a valid rule for the target element, it will overwrite any valid media queries which are 'higher up'. You can make use off only min-width
(mobile-first) or max-width
(desktop-first) queries in this regard (without mixing them). This is further explained here.