e4d js conference responsive web design - js-il.com

32
Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com | Yitzchak Meirovi Web Developer Instructo Israel Financ Ministry Responsive Web Design The Art & Science Israel JavaScript Conference

Upload: eyal-vardi

Post on 10-May-2015

430 views

Category:

Technology


0 download

DESCRIPTION

js-il.com

TRANSCRIPT

Page 1: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Yitzchak MeirovichWeb Developer, Instructor

Israel Finance Ministrysite: javascriptphp.com

Responsive Web DesignThe Art & Science

Israel JavaScript Conference

Page 2: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Why use Responsive Web Design?

Page 3: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

The Good News and the Bad News

Need for Self study

RWD is still being debated

The Science is easy The Art is hard

Testing and implementation are challenging

Will learn the technique to implement RWD

Will hear a story of RWD deployed to millions of users successfully

Will get tips, tricks and best practices

Page 4: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

איתור

מוטבים

• Introducing מוטבים and the need for איתורRWD

Science

• The Science of Responsive Web Design (RWD)

Art

• Design approach

Test

• Testing and Debugging

Rules

• Rules/Suggestions for a successful implementation of RWD

Page 5: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

מוטבים איתור

Page 6: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Defining a RWD Site Website rolled out to

millions

Needed to be Light, Lean and Lightning fast

Non-reflexive, responsive server infrastructure unlike Amazon S3

Want mobile but no history of mobile at the Ministry and no hardware devices

Short development time

Page 7: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Defining a RWD Site No time/ability to learn

native mobile code (obj C, java)

Use current skill-sets

Needed to be maintainable

Small team

High profile project watched at the highest levels

NO PRESSURE!

Page 8: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Technical Specs

HTML 4/5

CSS3

jQuery, jQuery Mobile, Mobiscroll

Why jQuery Mobile was rejected

C# .NET

Oracle

Opened web port for testing (device surfing)

Back-end Front-end

Page 9: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Site Design and Layout Started as usual – single layout design Desktop first approach

This was a mistake!

Page 10: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

The Science of RWD

Page 11: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Responsive WebCurrent Development

Standalone page, multiple files

Fixed-width layouts

Focus on pixels

Doesn’t display well on mobile

Single page/file

Fluid layouts

Focus on EMs / %

Display adjusts to different layouts and orientations

RWD Development

Inflexible Flexible

Page 12: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Responsive WebIngredients

CSS Reset

A flexible, grid-based layout

Flexible images and media

Media queries, a module from the CSS3 specification

http://responsivewebdesign.com/robot/

http://www.starbucks.com/

Page 13: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

CSS ResetBrowser Compatibility

Each browser calculates differently:1. Blocks2. Margins3. Padding

CSS Reset’s normalize cross-browser incompatibility for CSS layouts

http://meyerweb.com/eric/tools/css/reset/

http://html5boilerplate.com/

Page 14: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Flexible TypesettingResponsive fonts

Font = 100% = 16px (default)Fonts will always be proportionalbody {

background-color: #DCDBD9;color: #2C2C2C; font: normal 100% Cambria,

Georgia;}h1 a {

color: #747474; font: bold 11px Arial, sans-

serif; letter-spacing: 0.15em; text-transform: uppercase; text-decoration: none;

}

target / context = result

Secret Formula

24 / 16 = 1.5

h1 { /* 24px / 16px */ font-size: 1.5em; }

11 / 24 = 0.458333333333333

Target = 11px, headline = 24px= 45.8333333333333%

Page 15: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Fixed GridBlocks with Gutters

Proportional blocksMargins keep blocks lined up

#page { width: 960px; margin: 0 auto;

}

Non-responsive

960 fixed width

12 columns

6px gutters

69px columns

30px margin (R/L)

900/12 = 75-69=6

Non-fluid

Page 16: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Flexible GridBlocks with Gutters

Proportional blocksMargins keep blocks lined up

#page { width: 90%;

margin: 36px auto;}

Responsive

.blog { margin: 0 auto 53px; width: 93.75%; /* 900px / 960px */}

900 / 960 = 0.9375

Fluid

Page 17: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Flexible ImagesFLUID Imagesimg { max-width: 100%; height: auto; width: auto\9; /* ie8 */ }

Image max-width : 100% and height: auto works in IE7, but not in IE8 (weird IE bug). To fix this, you need to add width : auto\9 for IE8.

Page 18: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Media QueriesCSS2 Queries

@media screen and (device-pixel-ratio: 1.5){ /*adjust your layout for 1.5 hardware pixels to each reference pixel*/}

<link rel="stylesheet" href="paper.css" media="print" />

CSS3 Queries

@media print {body {

font-size: 15pt;}

}

@media screen and (min-device-width: 480px) and (orientation: landscape){

body {font-size: 100%;

}}

List of Device Features

widthheightdevice-widthdevice-heightorientationaspect-ratiodevice-aspect-ratiocolorcolor-indexmonochromeresolutionscangrid

http://stephen.io/mediaqueries/

http://www.javascriptkit.com/dhtmltutors/cssmediaqueries2.shtml

Page 19: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

CSS Grid Systems960.gs

Twitter Bootstrap12-column responsive grid

JavaScript plugins

Fixed width and Fluid grids

12/16/24 default grid layouts

Customizer Form controls

Typography

Customizer

Page 20: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Becoming ResponsiveMust Have

<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">

Flexible layout with media queries layered upon that non-fixed foundation

Flexible Images

Flexible Fonts

Responsive design is, I believe, one part design philosophy, one part front-end development strategy. And as a development strategy, it’s meant to be evaluated to see if it meets the needs of the project you’re working on. - Ethan Marcotte

Page 21: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

The Art of RWD

Page 22: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Design Approach

5 Dimensions Mobile First

Functionality Fluid not Fixed

Devices

Page 23: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Thinking in 5 Dimensions

Desktop

TabletPortrait

TabletLandscape

MobilePortrait

MobileLandscape

Page 24: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Mobile 1st Strategy

Why do people use your site?

Know your users goals

Decide which devices to support

Additive Expansionist

Non-reductionist

Pixels vs % vs EMs

Focus on functionality over sexy

Semantic HTML

Who determines which image to serve up?

JavaScript Libraries

Page 25: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Testing & Debugging

Page 26: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Testing

Emulators

Devices

Wireframe

Ghosting

ADB

Browsers

RippleChrome

Debugger

Chrome/SafariiOS vs Android

Adobe InspectCrossbrowsertesting.com

Android Bridge

Adobe Edge ReflowWirefy

Android/iOSVersion?

Mobile/Tablet

Page 27: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Rules for RWD

Page 28: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Rules for Successful Rollout No browser sniffing

Feature testing

Don’t disable zoom

Performance Oriented

Page 29: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Rules for Successful Rollout Start with mockups in 5

dimensions (Balsamiq)Target screens on major devices

Images Resources Use CSS3 and Sprites

Compress HTML,CSS,JS Resource Downloads

Page 30: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Page 31: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Page 32: E4D js conference responsive web design - js-il.com

Israel JavaScript Conference | 03 – 6325707 | [email protected] | www.js-il.com |

Thanksjavascriptphp.com

Yitzchak MeirovichWeb Developer, [email protected]