Reputation: 6318
Quite simply, for as long as ive been using media queries, ive had a problem where when trying to combine them like so(below)
@media screen and (max-width: 600px) and (max-height:400px) {
/* code here */
}
it NEVER works, i always have to seperate them like so
@media screen and (max-width: 600px) {
/* code here */
}
then
@media screen and (max-height: 600px) {
/* code here */
}
As an example, here is some code to show what i mean.
the first link is with the media queries combined.(doesnt work)
and this second link is with them separated.(works)
http://somdow.com/4testing/b/index2.html
Not a huge deal but after a while, it does bloat the code somewhat plus, it should work which leaves me stumped.
Any ideas as to why? Thanks in advanced.
Upvotes: 0
Views: 70
Reputation: 172
@media screen and (max-width: 600px) and (max-height:400px) {
/* code 1 */
}
works very well, but only happens if the width is less than 600px and the height is less 400px (the two conditions have to match):
What you want is an OR condition (not an AND) and you can acheive this like that:
@media screen and (max-width: 600px), screen and (max-height: 400px) {
/* code 1 */
}
Upvotes: 3