Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3...

114
Adapt and respond MOBILE-FRIENDLY LAYOUTS BEYOND THE DESKTOP Patrick H. Lauke / standards.next / 3 March 2012

description

 

Transcript of Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3...

Page 1: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

Adapt and respond MOBILE-FRIENDLY LAYOUTS BEYOND THE DESKTOP

Patrick H. Lauke / standards.next / 3 March 2012

Page 2: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

mobile webis increasingly important

Page 3: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

we need a site that works on iPhone

Page 4: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

oh, and on the iPad

Page 5: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

“remove iPhone from ass”Peter-Paul Koch, The iPhone obsession

www.quirksmode.org/blog/archives/2010/02/the_iphone_obse.html

Page 6: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 7: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

sites that work on (almost) all mobile devices

Page 8: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 9: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

3 approaches

Page 10: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

1. do nothing

Page 11: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

moved beyond WAP or text

Page 12: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

modern mobile browserscan handle the “real web”

Page 13: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 14: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 15: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

“but the mobile context...”

Page 16: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

“Desktop computers and mobile devices are so different that the only way to offer a great user experience is to create two

separate designs — typically with fewer features for mobile.”www.useit.com/alertbox/mobile-redesign.html

Page 17: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

twitter.com/#!/stephenhay/status/23350345962889216

Page 18: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

2. separate mobile site(m.flickr.com, mobile.mysite.com, ...)

Page 19: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

beware browser sniffingphoto: http://www.flickr.com/photos/timdorr/2096272747/

Page 20: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

let the user decide:diet or full fat?

Page 21: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 22: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 23: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 24: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 25: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 26: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

“refactored” for small displays,

not dumbed down for mobile

Page 27: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

3. single adaptive site

Page 28: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

nothing new

Page 29: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

www.alistapart.com/articles/dao

The Sage “... accepts the ebb and flow of things,

Nurtures them, but does not own them,”Tao Te Ching; 2 Abstraction

Page 30: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

how to take “desktop” layout to “mobile”?

Page 31: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

CSS 2 Media Types

Page 32: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

Media types

all brailleembossed handheldprint projectionscreen speechtty tv

Page 33: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 34: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

CSS 2.1 Media Types

<link rel="stylesheet" ... media="print" href="...">

@import url("...") print;

@media print {

// insert CSS rules here

}

Page 35: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

CSS 3 Media Queries“...the new hotness” Jeffrey Zeldman

http://www.zeldman.com/2010/04/08/best-aea-yet/

Page 36: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

CSS 3 Media Queries

● builds on CSS 2.1 Media Types concept● more granular control (not just screen, print...)

http://www.w3.org/TR/css3-mediaqueries/

Page 37: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

Media features

width colorheight color-indexdevice-width monochromedevice-height resolutionorientation scanaspect-ratio griddevice-aspect-ratio

Page 38: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

CSS 3 Media Queries

<link rel="stylesheet" ...

media="screen and (max-width:480px)" href="...">

@import url("...") screen and (max-width:480px);

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

// insert CSS rules here

}

Page 39: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

Multiple expressions – and keyword

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

// screen device and width > 180px

// and width < 480px

}

Page 40: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

Multiple expressions – comma separated

@media screen and (min-width:800px),

print and (min-width:20em) {

// screen device with width > 800px

// or print device with width > 20em

}

Page 41: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

Negative expressions – not keyword

@media not screen and (min-width:800px) {

// not applied to screen device

// with width > 800px

}

Page 42: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

Exclusive expressions – only keyword

@media only screen and (min-width:800px) {

// only applied to screen device

// with width > 800px

}

Page 43: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

Multiple media queries/* “The absence of a media query is the first media query” Bryan Rieger */

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

// screen device and width < 480px

}

@media screen and (max-width:980px) {

// screen device and width < 980px

}

@media screen and (min-width:980px) {

// screen device and width > 980px

}

Page 44: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

http://mediaqueri.es

Page 45: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

http://mediaqueri.es

Page 46: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

http://mediaqueri.es

Page 47: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

http://mediaqueri.es

Page 48: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

www.themaninblue.com/writing/perspective/2004/09/21

Page 49: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

design approaches using media queries

Page 50: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

easy-readers.net/books/adaptive-web-design

Page 51: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

www.alistapart.com/articles/responsive-web-design

Page 52: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

grid-based layouts

Page 53: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

www.subtraction.com/2007/03/19/oh-yeeaahh

Page 54: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

www.subtraction.com/2007/03/19/oh-yeeaahh

Page 55: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

www.alistapart.com/articles/fluidgrids

Page 56: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 57: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

Responsive Web Design™

fluid grid + fluid images + media queries

Page 58: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

bostonglobe.com

Page 59: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 60: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 61: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

adaptive vs responsive?

Page 62: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

“not a magic bullet...”

Page 63: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

unsolved mysteries…

Page 64: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 65: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 66: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

www.opera.com/developer/tools/mobile

Page 67: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 68: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

mobile devices lie

Page 69: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

physical vs virtual pixels

Page 70: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 71: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 72: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

viewport metasuggests an initial layout viewport

and zoom

Page 73: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

viewport meta

<meta name="viewport" content="width=480">

<meta name="viewport" content="width=480, user-scalable=no">

http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariWebContent/UsingtheViewport/UsingtheViewport.html

Page 74: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

Viewport properties

width initial-scaleheight minimum-scaleuser-scalable maximum-scale

Page 75: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 76: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 77: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

<meta name="viewport" content="width=device-width">

Page 78: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 79: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

high-dpi devices lie twice

Page 80: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

<meta name="viewport" content="width=device-width,

target-densitydpi=device-dpi">

Page 81: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 82: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

“interesting” iOS quirk

Page 83: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 84: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 85: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

confused?a practical example…

Page 86: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 87: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 88: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

<meta name="viewport" content="width=550">

Page 89: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

<meta name="viewport" content="width=550">

Page 90: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

<meta name="viewport" content="width=550">

Page 91: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

<meta name="viewport" content="width=550,maximum-scale=1.0">

Page 92: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

<meta name="viewport" content="width=550,maximum-scale=1.0,

target-densitydpi=device-dpi">

Page 93: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

maximum-scale=1.0

breaks zooming!

Page 94: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

JavaScript approaches to selectively apply viewport meta...argh!

Page 95: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

CSS Device Adaptation@viewport {

width: 320px;

zoom: 2.3;

user-zoom: fixed;

}

www.w3.org/TR/css-device-adapt

only works in Opera Mobile 11+ at the moment, with -o- prefix dev.opera.com/articles/view/an-introduction-to-meta-viewport-and-viewport

Page 96: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

Viewport properties

width / min-width / max-width user-zoom

height / min-height / max-height orientation

zoom / min-zoom / max-zoom resolution

Page 97: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

<meta name="viewport" content="width=550">

@-o-viewport {

width: 550px;

}

Page 98: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

<meta name="viewport" content="width=550,maximum-scale=1.0,

target-densitydpi=device-dpi">

@-o-viewport {

width: 550px;

max-zoom: 1;

resolution: device;

}

Page 99: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

/* selective viewport via CSS */

@media … {

@-o-viewport {

… /* for propellerheads */

}

}

Page 100: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

<meta name="viewport" content="width=550,maximum-scale=1.0,target-densitydpi=device-dpi">

@media screen {

@-o-viewport {

/* undo meta viewport settings */

width: auto; max-zoom: auto;

}

}

@media screen and (max-device-width: 550px) {

@-o-viewport {

/* 550px viewport on small screen devices */

width: 550px;

}

}

Page 101: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 102: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 103: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012
Page 104: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

<meta name="viewport" content="width=550,maximum-scale=1.0,target-densitydpi=device-dpi">

@media screen {

@-o-viewport {

/* undo meta viewport settings */

width: auto; max-zoom: auto;

}

}

@media screen and (max-device-width: 550px) {

@-o-viewport {

/* 550px viewport on small screen devices */

width: 550px;

}

}

Page 105: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

@-o-viewport {

/* minimum of 550px viewport width */

width: 550px auto; max-zoom: auto;

}

Page 106: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

more unsolved mysteries

Page 107: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

Responsive Web Design™

fluid grid + fluid images + media queries

Page 108: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

/* fluid image based on parent container */

img { max-width:100%; }

Page 109: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

Responsive Web Design™

fluid grid + fluid images + media queries

Page 110: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

stephanierieger.com/the-trouble-with-android

Page 111: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

www.zeldman.com/2011/12/29/state-of-the-web-of-apps-devices-and-breakpoints

Page 112: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

“embrace the fluidity,don't fight it”

Page 113: Adapt and respond - mobile-friendly layouts beyond the desktop - standards>next / Manchester / 3 March 2012

http://futurefriend.ly