Adaptive layouts - standards>next Manchester 23.03.2011

41
Adaptive layouts Patrick H. Lauke / standards>next / Manchester / 23 March 2011 MAKING YOUR SITE CROSS-DEVICE FRIENDLY

description

Making your site cross-device friendly standards>next / Manchester / 23 March 2011

Transcript of Adaptive layouts - standards>next Manchester 23.03.2011

Page 1: Adaptive layouts - standards>next Manchester 23.03.2011

Adaptive layouts

Patrick H. Lauke / standards>next / Manchester / 23 March 2011

MAKING YOUR SITE CROSS-DEVICE FRIENDLY

Page 2: Adaptive layouts - standards>next Manchester 23.03.2011

we need a site that works on iPhone

Page 3: Adaptive layouts - standards>next Manchester 23.03.2011

...works on iPhone...oh, and iPad

Page 4: Adaptive layouts - standards>next Manchester 23.03.2011

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

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

Page 5: Adaptive layouts - standards>next Manchester 23.03.2011

make your site work on all (most) mobile devices

Page 6: Adaptive layouts - standards>next Manchester 23.03.2011
Page 7: Adaptive layouts - standards>next Manchester 23.03.2011

don't do browser sniffing

http://www.flickr.com/photos/timdorr/2096272747/

Page 8: Adaptive layouts - standards>next Manchester 23.03.2011

CSS 2 Media Types

Page 9: Adaptive layouts - standards>next Manchester 23.03.2011

Media types

all brailleembossed handheldprint projectionscreen speechtty tv

Page 10: Adaptive layouts - standards>next Manchester 23.03.2011

CSS 2.1 Media Types

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

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

@media print { // insert CSS rules here}

Page 11: Adaptive layouts - standards>next Manchester 23.03.2011

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

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

Page 12: Adaptive layouts - standards>next Manchester 23.03.2011

CSS 3 Media Queries

● build and extend CSS 2.1 Media Types● more granular control of capabilities

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

Page 13: Adaptive layouts - standards>next Manchester 23.03.2011

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

Page 14: Adaptive layouts - standards>next Manchester 23.03.2011

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 15: Adaptive layouts - standards>next Manchester 23.03.2011

Multiple expressions – and keyword@media screen and (min-width:180px) and (max-width:480px) { // screen device and width > 180px // and width < 480px }

Page 16: Adaptive layouts - standards>next Manchester 23.03.2011

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 17: Adaptive layouts - standards>next Manchester 23.03.2011

Negative expressions – not keyword@media not screen and (min-width:800px) { // not applied to screen device // with width > 800px}

Page 18: Adaptive layouts - standards>next Manchester 23.03.2011

Negative expressions – only keyword@media only screen and (min-width:800px) { // only applied to screen device // with width > 800px}

Page 19: Adaptive layouts - standards>next Manchester 23.03.2011

Multiple media queries@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 20: Adaptive layouts - standards>next Manchester 23.03.2011

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

Page 21: Adaptive layouts - standards>next Manchester 23.03.2011

http://mediaqueri.es

Page 22: Adaptive layouts - standards>next Manchester 23.03.2011

http://mediaqueri.es

Page 23: Adaptive layouts - standards>next Manchester 23.03.2011

http://mediaqueri.es

Page 24: Adaptive layouts - standards>next Manchester 23.03.2011

http://mediaqueri.es

Page 25: Adaptive layouts - standards>next Manchester 23.03.2011

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

Page 26: Adaptive layouts - standards>next Manchester 23.03.2011

viewport meta

Page 27: Adaptive layouts - standards>next Manchester 23.03.2011

physical vs virtual pixels

Page 28: Adaptive layouts - standards>next Manchester 23.03.2011
Page 29: Adaptive layouts - standards>next Manchester 23.03.2011

mobile devices lie“to lie is to state something with disregard to the truth with the intention

that people will accept the statement as truth” thanks wikipedia

Page 30: Adaptive layouts - standards>next Manchester 23.03.2011

viewport metasuggests sizing to mobile browser

Page 31: Adaptive layouts - standards>next Manchester 23.03.2011

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 32: Adaptive layouts - standards>next Manchester 23.03.2011

Viewport properties

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

Page 33: Adaptive layouts - standards>next Manchester 23.03.2011
Page 34: Adaptive layouts - standards>next Manchester 23.03.2011
Page 35: Adaptive layouts - standards>next Manchester 23.03.2011

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

Page 36: Adaptive layouts - standards>next Manchester 23.03.2011
Page 37: Adaptive layouts - standards>next Manchester 23.03.2011
Page 38: Adaptive layouts - standards>next Manchester 23.03.2011

CSS Device Adaptation@viewport { width: device-width;}

@viewport { width: 320px; zoom: 2.3; user-zoom: fixed;}

dev.w3.org/csswg/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 39: Adaptive layouts - standards>next Manchester 23.03.2011

Viewport properties

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

height / min-height / max-height orientation

zoom / min-zoom / max-zoom

Page 40: Adaptive layouts - standards>next Manchester 23.03.2011

high-dpi devices...is where my brain starts to melt

dev.opera.com/articles/view/an-introduction-to-meta-viewport-and-viewportdeveloper.android.com/reference/android/webkit/WebView.html