0

So there are two divs as below:

/*for ipad portrait and landscape*/
@media only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) {
    .aclass {
        display: block;
        background-color: antiquewhite;
    }
    .bclass {
        display: none;
    }
}

/*for medium device*/
@media only screen 
and (min-width : 992px) 
and (max-width : 1200px) {
    .aclass {
        display: none;
    }
    .bclass {
        display: block;
        background-color: aquamarine;
    }
}
<div class="hidden-xs aclass">div 1</div>
<div class="hidden-xs bclass">div 2</div>

I want aclass to be applied only in ipad and bclass to be applied in medium devices like desktop. The problem arises in Ipad landscape mode where bclass is applied because of the min-width: 992px, but I want aclass to be applied here. How do I solve this issue?

2 Answers2

0

You can also use max-height/min-height and/or max-device-height/min-device-height in the media queries and combine that with your existing queries.

Johannes
  • 64,305
  • 18
  • 73
  • 130
0

Have you tried using and (orientation: landscape)? This is a media query constraint that only enforces CSS the rules if the device is in landscape mode. Works the same for orientation: portrait

Ryan
  • 393
  • 7
  • 22