SlideShare une entreprise Scribd logo
1  sur  14
Using Responsive Design in the Mobile Web 
HTML5DevConf 
Chris Perkins - Intel 
Intel Confidential — Do Not Forward
2 
Introductory Equations 
Someone told me that each equation I included in the book would halve the sales – Stephen Hawking 
 Speaker = Chris Perkins 
 Layout + Mobile Web = Challenging 
 Design Choices x Technologies x Libraries x Devices > Number.MAX_VALUE
3 
Responsive Design 
Power has to be insecure to be responsive – Ralph Nader 
 Designing a layout that works on a variety of screen sizes, orientations, and 
devices. The design responds to its environment. 
 vs. Adaptive Design 
 Includes 
 @media queries 
 %, em (vw & vh) coordinates 
 redirects 
 javascript
@media queries 
4 
The Basics 
 @media 
 min-width: / max-width 
 orientation: landscape / portrait 
 and 
 https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries 
 device-width, aspect-ratio, etc. 
 only, not 
 print, screen, handheld, all, …
Retina Images 
5 
 background-image css property 
 Q: what about <img> tag? 
 A: Use JS. Google “retina <img>” 
<img src=“little_baby.jpg” data-src2x=“big_baby.jpg”>
6 
Landscape / Portrait Only 
You don’t change the course of history by turning the faces of portraits to the wall – Jawaharlal Nehru 
 Cordova config.xml (for Cordova CLI or PhoneGapBuild) 
 <preference name="orientation" value="portrait" /> 
 Intel XDK 
 Projects Pane Settings (once for each desired platform) 
 Only for Builds (not Emulator or Previewing)
layout 
7 
@media & float 
 Floating boxes 
 float:left 
 min-width:250px 
 margin:0px 
 box-sizing:border-box 
 @media queries set width 
 25% for 1000px or greater 
– 4 x 250 = 1000 
 33% for 750 – 1000 
– 3 x 250 = 750
8 
@media & float : Frameworks and Tools 
- 
 Grid Systems 
 Zurb Foundation (foundation.zurb.com) 
 Twitter Bootstrap 
 960.gs 
 Many others 
 Tools 
 Adobe Edge Reflow 
 Intel XDK (App Designer)
layout 
9 
flexbox 
 Much Simpler. 
 Just works. 
 Supposedly less well supported 
– Android 4.3 and earlier use “old” spec. 
– May require –webkit prefix 
– Crosswalk OK 
– IE 11 OK. IE 10 uses 2012 spec. 
– http://caniuse.com/#search=flexbox
javascript & @media 
10 
- 
 window.matchMedia(‘(max-width: 400px)’) 
 { 
– media: {String}, 
– matches:{Boolean}, 
– removeListener:{Function}, 
– addListener:{Function} } 
 ‘(max-width:400px) and 
(orientation:landscape)’ etc. OK 
 But no @media
11 
redirect 
JavaScript is only redirect solution for Cordova/PhoneGap apps 
 Issues 
 A full “restart” of app 
– At start: palatable 
– While running: difficult 
– OK for phone versus tablet. 
– But bad choice for portrait vs. landscape. 
 Burden of transferring application state 
– via localStorage etc 
 deviceready 
 Summary: Single Page App is still your best friend.
Vertical sizing 
12 
- 
 Sizing of element vs text 
 vh, vmax/vmin not backward compatible on 
Android 
 em & rem 
 Zoom via meta 
– <meta name="viewport" content="initial-scale=2"> 
– Not well supported. 
– Tricky. 
 @viewport ? 
– Draft. Unsupported.
13 
Links 
- 
 https://github.com/cperkinsintel/responsive_design_pres 
 http://xdk-software.intel.com/
Intel Confidential — Do Not Forward

Contenu connexe

Plus de Intel® Software

Plus de Intel® Software (20)

Software AI Accelerators: The Next Frontier | Software for AI Optimization Su...
Software AI Accelerators: The Next Frontier | Software for AI Optimization Su...Software AI Accelerators: The Next Frontier | Software for AI Optimization Su...
Software AI Accelerators: The Next Frontier | Software for AI Optimization Su...
 
Advanced Techniques to Accelerate Model Tuning | Software for AI Optimization...
Advanced Techniques to Accelerate Model Tuning | Software for AI Optimization...Advanced Techniques to Accelerate Model Tuning | Software for AI Optimization...
Advanced Techniques to Accelerate Model Tuning | Software for AI Optimization...
 
Reducing Deep Learning Integration Costs and Maximizing Compute Efficiency| S...
Reducing Deep Learning Integration Costs and Maximizing Compute Efficiency| S...Reducing Deep Learning Integration Costs and Maximizing Compute Efficiency| S...
Reducing Deep Learning Integration Costs and Maximizing Compute Efficiency| S...
 
AWS & Intel Webinar Series - Accelerating AI Research
AWS & Intel Webinar Series - Accelerating AI ResearchAWS & Intel Webinar Series - Accelerating AI Research
AWS & Intel Webinar Series - Accelerating AI Research
 
Intel Developer Program
Intel Developer ProgramIntel Developer Program
Intel Developer Program
 
Intel AIDC Houston Summit - Overview Slides
Intel AIDC Houston Summit - Overview SlidesIntel AIDC Houston Summit - Overview Slides
Intel AIDC Houston Summit - Overview Slides
 
AIDC NY: BODO AI Presentation - 09.19.2019
AIDC NY: BODO AI Presentation - 09.19.2019AIDC NY: BODO AI Presentation - 09.19.2019
AIDC NY: BODO AI Presentation - 09.19.2019
 
AIDC NY: Applications of Intel AI by QuEST Global - 09.19.2019
AIDC NY: Applications of Intel AI by QuEST Global - 09.19.2019AIDC NY: Applications of Intel AI by QuEST Global - 09.19.2019
AIDC NY: Applications of Intel AI by QuEST Global - 09.19.2019
 
Advanced Single Instruction Multiple Data (SIMD) Programming with Intel® Impl...
Advanced Single Instruction Multiple Data (SIMD) Programming with Intel® Impl...Advanced Single Instruction Multiple Data (SIMD) Programming with Intel® Impl...
Advanced Single Instruction Multiple Data (SIMD) Programming with Intel® Impl...
 
Build a Deep Learning Video Analytics Framework | SIGGRAPH 2019 Technical Ses...
Build a Deep Learning Video Analytics Framework | SIGGRAPH 2019 Technical Ses...Build a Deep Learning Video Analytics Framework | SIGGRAPH 2019 Technical Ses...
Build a Deep Learning Video Analytics Framework | SIGGRAPH 2019 Technical Ses...
 
Bring Intelligent Motion Using Reinforcement Learning Engines | SIGGRAPH 2019...
Bring Intelligent Motion Using Reinforcement Learning Engines | SIGGRAPH 2019...Bring Intelligent Motion Using Reinforcement Learning Engines | SIGGRAPH 2019...
Bring Intelligent Motion Using Reinforcement Learning Engines | SIGGRAPH 2019...
 
RenderMan*: The Role of Open Shading Language (OSL) with Intel® Advanced Vect...
RenderMan*: The Role of Open Shading Language (OSL) with Intel® Advanced Vect...RenderMan*: The Role of Open Shading Language (OSL) with Intel® Advanced Vect...
RenderMan*: The Role of Open Shading Language (OSL) with Intel® Advanced Vect...
 
AIDC India - AI on IA
AIDC India  - AI on IAAIDC India  - AI on IA
AIDC India - AI on IA
 
AIDC India - Intel Movidius / Open Vino Slides
AIDC India - Intel Movidius / Open Vino SlidesAIDC India - Intel Movidius / Open Vino Slides
AIDC India - Intel Movidius / Open Vino Slides
 
AIDC India - AI Vision Slides
AIDC India - AI Vision SlidesAIDC India - AI Vision Slides
AIDC India - AI Vision Slides
 
Enhance and Accelerate Your AI and Machine Learning Solution | SIGGRAPH 2019 ...
Enhance and Accelerate Your AI and Machine Learning Solution | SIGGRAPH 2019 ...Enhance and Accelerate Your AI and Machine Learning Solution | SIGGRAPH 2019 ...
Enhance and Accelerate Your AI and Machine Learning Solution | SIGGRAPH 2019 ...
 
Intel® Open Image Denoise: Optimized CPU Denoising | SIGGRAPH 2019 Technical ...
Intel® Open Image Denoise: Optimized CPU Denoising | SIGGRAPH 2019 Technical ...Intel® Open Image Denoise: Optimized CPU Denoising | SIGGRAPH 2019 Technical ...
Intel® Open Image Denoise: Optimized CPU Denoising | SIGGRAPH 2019 Technical ...
 
ANYFACE*: Create Film Industry-Quality Facial Rendering & Animation Using Mai...
ANYFACE*: Create Film Industry-Quality Facial Rendering & Animation Using Mai...ANYFACE*: Create Film Industry-Quality Facial Rendering & Animation Using Mai...
ANYFACE*: Create Film Industry-Quality Facial Rendering & Animation Using Mai...
 
Ray Tracing with Intel® Embree and Intel® OSPRay: Use Cases and Updates | SIG...
Ray Tracing with Intel® Embree and Intel® OSPRay: Use Cases and Updates | SIG...Ray Tracing with Intel® Embree and Intel® OSPRay: Use Cases and Updates | SIG...
Ray Tracing with Intel® Embree and Intel® OSPRay: Use Cases and Updates | SIG...
 
Use Variable Rate Shading (VRS) to Improve the User Experience in Real-Time G...
Use Variable Rate Shading (VRS) to Improve the User Experience in Real-Time G...Use Variable Rate Shading (VRS) to Improve the User Experience in Real-Time G...
Use Variable Rate Shading (VRS) to Improve the User Experience in Real-Time G...
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Using Responsive Design in the Mobile Web

  • 1. Using Responsive Design in the Mobile Web HTML5DevConf Chris Perkins - Intel Intel Confidential — Do Not Forward
  • 2. 2 Introductory Equations Someone told me that each equation I included in the book would halve the sales – Stephen Hawking  Speaker = Chris Perkins  Layout + Mobile Web = Challenging  Design Choices x Technologies x Libraries x Devices > Number.MAX_VALUE
  • 3. 3 Responsive Design Power has to be insecure to be responsive – Ralph Nader  Designing a layout that works on a variety of screen sizes, orientations, and devices. The design responds to its environment.  vs. Adaptive Design  Includes  @media queries  %, em (vw & vh) coordinates  redirects  javascript
  • 4. @media queries 4 The Basics  @media  min-width: / max-width  orientation: landscape / portrait  and  https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries  device-width, aspect-ratio, etc.  only, not  print, screen, handheld, all, …
  • 5. Retina Images 5  background-image css property  Q: what about <img> tag?  A: Use JS. Google “retina <img>” <img src=“little_baby.jpg” data-src2x=“big_baby.jpg”>
  • 6. 6 Landscape / Portrait Only You don’t change the course of history by turning the faces of portraits to the wall – Jawaharlal Nehru  Cordova config.xml (for Cordova CLI or PhoneGapBuild)  <preference name="orientation" value="portrait" />  Intel XDK  Projects Pane Settings (once for each desired platform)  Only for Builds (not Emulator or Previewing)
  • 7. layout 7 @media & float  Floating boxes  float:left  min-width:250px  margin:0px  box-sizing:border-box  @media queries set width  25% for 1000px or greater – 4 x 250 = 1000  33% for 750 – 1000 – 3 x 250 = 750
  • 8. 8 @media & float : Frameworks and Tools -  Grid Systems  Zurb Foundation (foundation.zurb.com)  Twitter Bootstrap  960.gs  Many others  Tools  Adobe Edge Reflow  Intel XDK (App Designer)
  • 9. layout 9 flexbox  Much Simpler.  Just works.  Supposedly less well supported – Android 4.3 and earlier use “old” spec. – May require –webkit prefix – Crosswalk OK – IE 11 OK. IE 10 uses 2012 spec. – http://caniuse.com/#search=flexbox
  • 10. javascript & @media 10 -  window.matchMedia(‘(max-width: 400px)’)  { – media: {String}, – matches:{Boolean}, – removeListener:{Function}, – addListener:{Function} }  ‘(max-width:400px) and (orientation:landscape)’ etc. OK  But no @media
  • 11. 11 redirect JavaScript is only redirect solution for Cordova/PhoneGap apps  Issues  A full “restart” of app – At start: palatable – While running: difficult – OK for phone versus tablet. – But bad choice for portrait vs. landscape.  Burden of transferring application state – via localStorage etc  deviceready  Summary: Single Page App is still your best friend.
  • 12. Vertical sizing 12 -  Sizing of element vs text  vh, vmax/vmin not backward compatible on Android  em & rem  Zoom via meta – <meta name="viewport" content="initial-scale=2"> – Not well supported. – Tricky.  @viewport ? – Draft. Unsupported.
  • 13. 13 Links -  https://github.com/cperkinsintel/responsive_design_pres  http://xdk-software.intel.com/
  • 14. Intel Confidential — Do Not Forward

Notes de l'éditeur

  1. Introduce Self: Chris Perkins. Work for Intel, on Intel XDK Have developed tools for developers or designers, including SiteGrinder, PhotoWebber and others Comment on slide. I cannot begin to cover, much less enumerate, all the choices, possible solutions, in an hour. Instead, going to focus on just one corner: Responsive Design. IMPORTANT: If you are developing for the mobile web, you need to be aware of the world your app will live in when on the phone. Not the world it is in while on your desktop. You get your app into the App Stores, and the first user to download it will likely have an older Android or iOS install and it’s built-in system webview is old and fragile. It wasn’t current when the phone was released, much less now. All your hard-earned mad-latest CSS skillz wither when facing these impassive bricks. The user cannot update that webview by simply updating their browser app on the phone. They must upgrade the underlying OS, and for many phones the manufacturer or carrier has either forgotten or prevented them from doing so.
  2. It was trendy a few years ago to distinguish Responsive Design from Adaptive Design. But, honestly, everyone is so tired these days no one cares. Excepting possibly some few pedants. NOTE: vh coordinates buggy on iOS. And vw, vh unsupported before Android 4.4 (except crosswalk).
  3. color-change demo Any CSS Property can be used. Float, font-size, NOTE: Media Queries are well supported. Everywhere but IE8.
  4. Retina-image demo Obviously, can be combined with and (min-width:400px) etc Will both images be loaded?
  5. Hey, since this is the Mobile Web and if you don’t care about browsers, don’t even bother with the rest of my talk.
  6. Layout demo Body margin:0 -- full bleed. Easier calculation. Min-width:250 means less thinking. All the media queries are expressed in multiples of that minimum width. We will use actual “width” in the media queries themselves. Margin:0 very important. Much much harder to think about with real margins. Use nested containers if you need real margins. Box-sizing:border-box. In this demo I’m using light blue borders as fake margins. This stunt will only work with box-sizing:border-box. Otherwise we are back to thinking again.
  7. Everything from the previous slide is well trodden ground. Many have come before and have simplified it with tools and libraries.
  8. Layout-flexbox demo. Use Chrome “Live Layout” mode It has been said that flexbox is finally CSS layout done right, and that it is an embarrassment that it has taken Much simpler. Just works. Note that we didn’t even need a media query in this example. (Note we might want @media (max-width:400px){ .container { flex-direction:column } } ) In my experience, this actually works pretty well across a wide variety of platforms. Recommend testing and planning for testing. Phone updates can’t be counted on. (w/ exception of Crosswalk)
  9. Notes: No ‘@media’ part. Very handy. Important
  10. redirect project demo For true web apps (served) the story may be different. Sessions/Cookies Phone versus Tablet is generally safe, because use can’t “change” their device by flipping it over or shaking it. Note: best to use _both_ check-at-start and listen-for-change .