Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Widths to use in media queries [closed]

What are the most important media query widths for all devices like desktops, tablets, laptops/Ipads, Iphones and Smartphones? Are there any standard widths for these devices?

like image 746
Nishantha Avatar asked May 23 '13 01:05

Nishantha


People also ask

Should I use max-width or min-width in media queries?

If you are designing your website for smaller devices first then set your initial breakpoints with min-width, whereas, if you are designing for larger devices first then use max-width. This post discusses min-width, and max-width media features in detail along with relevant examples.

What 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.

What is max-width in media query?

Taking a look at the CSS file, you'll notice that the media query has a minimum width of 320px and a maximum width of 576px . This just means that all the styles that will go into this rule will only be applicable to devices with extra-small and small widths.

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){ ... }


2 Answers

I'm looking everywhere for the best answer for this. Here what I found.

@media (min-width:320px) { /* smartphones, iPhone, portrait 480x320 phones */ } @media (min-width:481px) { /* portrait e-readers (Nook/Kindle), smaller tablets @ 600 or @ 640 wide. */ } @media (min-width:641px) { /* portrait tablets, portrait iPad, landscape e-readers, landscape 800x480 or 854x480 phones */ } @media (min-width:961px) { /* tablet, landscape iPad, lo-res laptops ands desktops */ } @media (min-width:1025px) { /* big landscape tablets, laptops, and desktops */ } @media (min-width:1281px) { /* hi-res laptops and desktops */ } 

I think this is better considering with mobile first approach. Start from mobile style sheet and then apply media queries relevant for other devices. Thanks for @ryanve. Here is the link.

like image 72
Nishantha Avatar answered Sep 20 '22 19:09

Nishantha


I find these are good breakpoints to start from but always test and tweak as you go. I'd also suggest using ems instead of px for dimensions for varied device dimensions and resolutions (reasons described here (http://blog.cloudfour.com/the-ems-have-it-proportional-media-queries-ftw/))

So the above queries would look like this:

@media (min-width:20em) { /* smartphones, iPhone, portrait 480x320 phones */ } @media (min-width:30.063em) { /* portrait e-readers (Nook/Kindle), smaller tablets @ 600 or @ 640 wide. */ } @media (min-width:40.063em) { /* portrait tablets, portrait iPad, landscape e-readers, landscape 800x480 or 854x480 phones */ } @media (min-width:60.063em) { /* tablet, landscape iPad, lo-res laptops ands desktops */ } @media (min-width:64.063em) { /* big landscape tablets, laptops, and desktops */ } @media (min-width:80.063em) { /* hi-res laptops and desktops */ } 

There is also a nifty pixel to em calculator online here (http://pxtoem.com/) For those of you not as familiar, including myself.

like image 45
Terri Swiatek Avatar answered Sep 20 '22 19:09

Terri Swiatek