Adaptive Layouts - standards>next London 28.05.2011

10,107 views
9,467 views

Published on

Random thoughts on making your site cross-device friendly
standards>next / London / 28 May 2011

Published in: Technology, Design
0 Comments
25 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
10,107
On SlideShare
0
From Embeds
0
Number of Embeds
14
Actions
Shares
0
Downloads
236
Comments
0
Likes
25
Embeds 0
No embeds

No notes for slide

Adaptive Layouts - standards>next London 28.05.2011

  1. Adaptive layoutsRANDOM THOUGHTS ON MAKING YOUR SITE CROSS-DEVICE FRIENDLYPatrick H. Lauke / standards>next / London / 28 May 2011
  2. we need a site that works on mobile
  3. we need a site that works on iPhone
  4. ...works on iPhone... oh, and iPad
  5. “remove iPhone from ass” Peter-Paul Koch, The iPhone obsession www.quirksmode.org/blog/archives/2010/02/the_iphone_obse.html
  6. make your site work on all (most) mobile devices
  7. what exactly is a“mobile device”?
  8. dont do browser sniffing http://www.flickr.com/photos/timdorr/2096272747/
  9. CSS 2 Media Types
  10. Media typesall brailleembossed handheldprint projectionscreen speechtty tv
  11. media="handheld"
  12. CSS 2.1 Media Types<link rel="stylesheet" ...media="print" href="...">@import url("...") print;@media print { // insert CSS rules here}
  13. CSS 3 Media Queries “...the new hotness” Jeffrey Zeldman http://www.zeldman.com/2010/04/08/best-aea-yet/
  14. CSS 3 Media Queries● build and extend CSS 2.1 Media Types● more granular control of capabilitieshttp://www.w3.org/TR/css3-mediaqueries/
  15. Media featureswidth colorheight color-indexdevice-width monochromedevice-height resolutionorientation scanaspect-ratio griddevice-aspect-ratio
  16. 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}
  17. Multiple expressions – and keyword@media screen and (min-width:180px) and (max-width:480px) { // screen device and width > 180px // and width < 480px}
  18. 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}
  19. Negative expressions – not keyword@media not screen and (min-width:800px) { // not applied to screen device // with width > 800px}
  20. Negative expressions – only keyword@media only screen and (min-width:800px) { // only applied to screen device // with width > 800px}
  21. 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}
  22. www.alistapart.com/articles/responsive-web-design
  23. http://mediaqueri.es
  24. http://mediaqueri.es
  25. http://mediaqueri.es
  26. http://mediaqueri.es
  27. www.themaninblue.com/writing/perspective/2004/09/21
  28. “not a magic bullet...”
  29. viewport meta
  30. physical vs virtual pixels
  31. mobile devices lie(to better serve the user)
  32. viewport metasuggests sizing to mobile browser
  33. viewport meta<meta name="viewport" content="width=320">http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariWebContent/UsingtheViewport/UsingtheViewport.html
  34. Viewport propertieswidth initial-scaleheight minimum-scaleuser-scalable maximum-scale
  35. <meta name="viewport" content="width=480">
  36. <meta name="viewport" content="width=550">
  37. <meta name="viewport" content="width=550">
  38. <meta name="viewport" content="width=550, maximum-scale=1.0">
  39. maximum-scale=1.0 breaks zooming!
  40. if (navigator.userAgent.match(/iPhone/i) ||navigator.userAgent.match(/iPad/i)) { var viewportmeta =document.querySelector(meta[name="viewport"]); if (viewportmeta) { viewportmeta.content = width=device-width, minimum-scale=1.0, maximum-scale=1.0; document.body.addEventListener(gesturestart,function() { viewportmeta.content = width=device-width, minimum-scale=0.25, maximum-scale=1.6; }, false); }}adactio.com/journal/4470
  41. device-width to the rescue?
  42. in Mobile Safari only: device-width always same (portrait/landscape) … WTF?
  43. high-dpi devices lieabout device-width
  44. <meta name="viewport" content="width=device-width">
  45. 480px / 160% = 300px
  46. <meta name="viewport" content="width=device-width, target-densitydpi=device-dpi">
  47. CSS Device Adaptation@viewport { width: 320px; zoom: 2.3; user-zoom: fixed;}dev.w3.org/csswg/css-device-adaptCurrently only in Opera Mobile 11 with -o- prefixdev.opera.com/articles/view/an-introduction-to-meta-viewport-and-viewport
  48. Viewport propertieswidth / min-width / max-width user-zoomheight / min-height / max-height orientationzoom / min-zoom / max-zoom
  49. @media + @viewport@media screen and (max-device-width: 550px) { @-o-viewport { width: 550px; }}only apply viewport width fixing on small-screen devices
  50. @viewport@-o-viewport { width: 550px auto;}minimum and maximum width
  51. BUG ALERT: Opera currently not re-running Media Queries on portrait/landscape switch
  52. www.opera.com/developer patrick.lauke@opera.com

×