Reputation: 15724
So I am working on my first responsive website which makes extensive use of media queries. I was wondering if there are some common page-widths I should optimize for.
I will probably have a maximum width (not going full fluid) I am thinking I'll have maybe 3-5 set widths with fun little CSS3 transitions between them (similar to how CSS Tricks works).
Currently the numbers I am using are somewhat arbitrary:
@media all and (max-width: 599px){...}
@media all and (min-width: 600px) and (max-width:799px){...}
@media all and (min-width: 800px) and (max-width:1024px){...}
@media all and (min-width: 700px) and (max-width: 1024px){...}
@media all and (min-width: 1025px) and (max-width: 1399px){...}
@media all and (min-width: 1400px){...}
Also, I think I have read that some mobile devices don't behave as expected (with @media
). Where does this come into play and how should I deal with these situations?
Upvotes: 53
Views: 77447
Reputation: 21
Based on my own needs, I came up with the following ... I call this breakpoints "For Mature Eyes" or "40+" :)
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body { font-size: 18px; } /* some font size for small viewport */
/* small viewport navigation (hamburger) */
@media screen and (min-width: 1100px) {
body { font-size: 20px; } /* some font size for big viewport */
/* css for big viewport navigation */
}
@media screen and (min-width: 1540px) {
body { font-size: 22px; } /* some font size for large viewport */
/* eventually css for large viewport */
}
</style>
</head>
Small viewport - no @media / small viewport menu, small fonts...
Big viewport - @media | min-width: 1100px / big viewport menu, middle fonts...
Large viewport - @media | min-width: 1540px / big fonts...
Why 1100px and 1540px ? Of course it is personal, but maybe it will be interesting for someone... Because of my eyes I use Windows 125% scaling and at 1920px monitor it becomes 1536px. On my 10" laptop with 1366px monitor and 125% scaling it becomes about 1093px (1100px will eventually cover and future large-resolution mobile phones in landscape).
Here you can check scaling if you use it: www.sirmium.org/test/px.html
Here you can find above breakpoints example (font scaling): www.sirmium.org/test/breakpoints.html
P.S. Of course, you can add Middle viewport or so...
Upvotes: 0
Reputation: 371331
When deciding on breakpoints for your media queries, consider these realities:
With so many viewport possibilities, matching breakpoints to specific devices doesn't sound like an efficient strategy. Just keeping up with what's popular, what's new, and what's changed will be a never-ending task.
A better approach may be to set breakpoints based on content and layout.
With this approach your site uses its natural breakpoints to adapt to all viewport sizes, rather than artificial breakpoints targeting currently common screen sizes.
This method is so simple and easy it may be hard to believe:
Of course, if you're designing mobile-first, then the process goes in reverse: Start with a narrow screen and work your way out.
With natural breakpoints you no longer need to focus on a giant universe of viewport sizes because your site will adapt to any device, both now and in the future.
According to one developer, this approach brings breakpoints full-circle to their original intent:
I'm not sure how we ever came up with the phrase "device-specific breakpoints" anyhow... As I've understood it, the term "breakpoint" was always a reference to where the content or layout would "break" (i.e. appear flawed) and thus you'd need to apply a media query at that point. But I guess that's just semantics, I just always thought it was common sense to refer to breakpoints in the context of content or layout.
~ Louis Lazaris, ImpressiveWebs
More information (external sites):
Upvotes: 44
Reputation: 1216
This is what I use...
@media screen and (max-width:320px) {}
@media screen and (min-width:321px) and (max-width:639px) {}
@media screen and (min-width:640px) and (max-width:959px) {}
@media screen and (min-width:960px) and (max-width:1279px) {}
@media screen and (min-width:1280px) and (max-width:1599px) {}
@media screen and (min-width:1600px) {}
@media screen and (min-width:1920px) {}
@media print {}
There are all kinds of others in there, as appropriate (min-width without max-width or max-width without min-width), but this is my base setup.
Personally, I never understood the odd widths that a lot of people use. For instance, 320 and up has Five CSS3 Media Query increments: 480, 600, 768, 992 and 1382px.
That doesn't make any sense to me. Logical breaks are at intervals of 320px (320, 640, 960, 1280, 1600, 1920). Note that these breaks can give a slightly different layout for pretty much any device in either orientation (omnia is 240x400, iphone is 320x480, droid x is 480x858, ipad is 768x1024, galaxy s3 is 720x1280, and they are talking 1920x1080 tablets).
JJ
Upvotes: 22
Reputation: 8472
Also, I would definitely recommend using device-width
for your mobile sizes, unless you want users to see your mobile styles when they resize their browser window on a non-mobile device. width
is the width of the viewport, and device-width
is the current resolution of the device.
Also, I think I have read that some mobile devices don't behave as expected (with @media).
You are correct. Many devices will not give you the width
or device-width
that you expect, especially when switching between landscape and portrait (they will often give the landscape width when in portrait). Device auto-zooming can also throw a wrench into things. Using the viewport meta tag can help with many of these issues. (More info on that here)
Upvotes: 44
Reputation: 12867
some resolutions to look for:
iphone screen (a lot of other smartphones have similar screen sizes: 960-by-640-pixel resolution at 326 ppi http://www.apple.com/iphone/specs.html
ipad screen (a lot of other tablets have similar screen sizes 1024-by-768-pixel resolution at 132 pixels per inch (ppi) http://www.apple.com/ipad/specs/
'normal' screen a lot of normal screens also have a 1024-by-768-pixels resolution, according to: http://www.w3schools.com/browsers/browsers_display.asp but I'm not vouching for their trustworthyness.
I'm looking for more data now.
Upvotes: 1