CSS media query to target iPad and iPad only?

CSS media query to target iPad and iPad only?

Finally found a solution from : Detect different device platforms using CSS

<link rel=stylesheet media=all and (device-width: 768px) and (device-height: 1024px) and (orientation:portrait) href=ipad-portrait.css />
<link rel=stylesheet media=all and (device-width: 768px) and (device-height: 1024px) and (orientation:landscape) href=ipad-landscape.css />

To reduce HTTP call, this can also be used inside you existing common CSS file:

@media all and (device-width: 768px) and (device-height: 1024px) and (orientation:portrait) {
  .ipad-portrait { color: red; } /* your css rules for ipad portrait */
}
@media all and (device-width: 1024px) and (device-height: 768px) and (orientation:landscape) {
  .ipad-landscape { color: blue; } /* your css rules for ipad landscape */
}

Hope this helps.

Other references:

I am a bit late to answer this but none of the above worked for me.

This is what worked for me

@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
    //your styles here
   }

CSS media query to target iPad and iPad only?

You need to target the device by its User Agent, using some script. The user agent for the iPad is:

Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10

Leave a Reply

Your email address will not be published.