Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Media Query for iPad and desktop (max-width)

Tags:

css

ipad

media

I want some CSS code to target both iPad and desktop with max-width: 768.

This (I don't know why, would be glad to know) doesn't work for the iPad (only desktop):

@media only screen and (max-width: 768px)

so I had to to this for the iPad:

@media only screen and (device-width: 768px)

However, I have the exact same code inside both media queries, and that I cannot accept.

I tried this also:

@media only screen and (max-width: 767px) or (device-width: 768px)

This one above doesn't work either - it actually works for the desktop, no matter what width, and not on iPad. Really strange.

How to target both iPad and desktop with same media query?

like image 633
zok Avatar asked Oct 25 '12 20:10

zok


People also ask

What is the max width for iPad?

The screen resolutions of different devices are listed below: Mobile (Smartphone) max-width: 480px. Low Resolution Tablets and ipads max-width: 767px. Tablets Ipads portrait mode max-width:1024px.

How do you write a media query for max width?

If you want to include both min and max width for responsiveness in the browser, then you can use the following: @media (min-width: 768px) and (max-width: 992px){...} @media (min-width: 480px) and (max-width: 767px) {...}

What are the screen sizes for media queries?

In my experience, 320px, 768px, and 1200px are the most commonly used; these three values should be sufficient for targeting smart phones, tablets/laptops, and desktops, respectively.

How do you set media queries between two widths?

You should use (min-width first): @media screen and (min-width:400px) and (max-width:900px){ ... }


1 Answers

I have used this. work for me in all device.

@media only screen and (min-width: 1024px) and (max-width: 1199px){

}

@media only screen and (min-width: 768px) and (max-width: 1023px){

}

@media only screen and (min-width: 480px) and (max-width: 767px){

}

@media only screen and (min-width: 0px) and (max-width: 479px){

}
like image 55
Amit Avatar answered Sep 20 '22 08:09

Amit