Responsive Web Design

85

description

Designing for the web is no longer what it used to be. The number of devices with web-browsing capabilities is growing at an increasing speed. RWD is an approach aimed to provide a solid viewing experience for a multiple of screens with one set of code.

Transcript of Responsive Web Design

Page 1: Responsive Web Design
Page 2: Responsive Web Design

About Me

• Julia Vishnevsky• .Net developer at ‘Yedioth Aharonot’

Daka90.co.il team• Co-founder & CTO at ‘Gigpo’• Keep in touch:

– Facebook– Linked In

Page 3: Responsive Web Design

WHY RESPONSIVE?

Page 4: Responsive Web Design

Motivation

The total number of people using the web on mobile devices is set to surpass desktops by 2015

Page 5: Responsive Web Design

• 77% of world's population has a mobile device

• Different devices and browser have different capabilities in terms of feature support

• People expect to be able to browse the web on their phones just as easily as they browse the web on a desktop computer

Page 6: Responsive Web Design

Different screen resolutions

Page 7: Responsive Web Design

Different screen resolutions

Page 8: Responsive Web Design

Different screen resolutions

Page 9: Responsive Web Design

POSSIBLE SOLUTIONS

Page 10: Responsive Web Design

Development Options

• Graceful Degradation

• Progressive Enhancement

• Mobile Specific Version

• Responsive Design

Page 11: Responsive Web Design

Graceful Degradation

• First build for the latest and greatest• Create a site using the newest features • Focus on the majority before catering to those

outside the mainstream• Add handlers for less capable devices• make sure older browsers don't choke on the

code and display the content

Page 12: Responsive Web Design

Pros & Cons

• Pros– Fault tolerance

• Cons– The content is displayed, but the experience might

be painful– Not a good experience for:

• the older browser user• the mobile devices that use less capable browsers

Page 13: Responsive Web Design

Progressive Enhancement

• Create a baseline experience first• Use layers to provide richer experience for

more capable browsers• Pros

– Everyone gets a good viewing experience• Cons

– Development time– Design restrictions

Page 14: Responsive Web Design

• Create a separate mobile site– Subset of functionality.

• Pros:– You can fully tailor the browsing experience for mobile users.

• Cons:– Mobile users won’t get the full experience.– Each new feature has to be developed twice, resulting in

large maintenance costs.– Still need to make adjustments for different screen

resolution

Mobile Specific Version

Page 15: Responsive Web Design

RESPONSIVE DESIGN

Page 16: Responsive Web Design

Responsive

• The design responds to– Device capabilities– Device type– Screen size and resolution– Orientation

Page 17: Responsive Web Design

The Father of Responsive Design

• Ethan Marcotte– Web designer, developer, speaker and author

• Ethan Marcotte coined the term responsive web design (RWD) in a May 2010 article in A List Apart

• http://alistapart.com/• http://alistapart.com/article/responsive-web-

design/

Page 18: Responsive Web Design

“Rather than tailoring disconnected designs to each of an ever-increasing number of web devices, we can treat them as facets of the same experience.”

Ethan Marcotte

Page 19: Responsive Web Design

EXAMPLES

Page 20: Responsive Web Design
Page 21: Responsive Web Design
Page 22: Responsive Web Design
Page 23: Responsive Web Design
Page 24: Responsive Web Design
Page 25: Responsive Web Design
Page 26: Responsive Web Design
Page 27: Responsive Web Design
Page 28: Responsive Web Design

Links

• http://www.bostonglobe.com• http://www.cacaotour.com/index.php/en/ho

me• http://foodsense.is/

Page 29: Responsive Web Design

IMPLEMENTATION

Page 30: Responsive Web Design

How Responsive Design Works

• It’s not a single piece of technology, but rather, a set of techniques and ideas that form a whole

• 3 main components– Fully fluid web design - %– Css media queries– JS

Page 31: Responsive Web Design

FLUID DESIGN

Page 32: Responsive Web Design

In The Past..

• We used to build fixed width layouts, centered

Page 33: Responsive Web Design

That doesn’t work anymore..

Page 34: Responsive Web Design

Fluid LayoutsFluid/liquid layout – the components havepercentage widths, and thus adjust to the user’sscreen resolution

Page 35: Responsive Web Design

% = Target / Context

Page 36: Responsive Web Design

0.76 = 720/ 940

Page 37: Responsive Web Design

0.23 = 220/ 940

Page 38: Responsive Web Design

Fluid Grid Frameworks

• Flexible way to create a responsive web site

Page 39: Responsive Web Design
Page 40: Responsive Web Design
Page 41: Responsive Web Design

Fluid Grid Frameworks

• Pros– No math required – just count the number of

columns you need– Scales to any width – uses percentage -

Responsive– It’s easy

Page 42: Responsive Web Design

Grid Frameworks

Less Framework 4 Bootstrap

Page 43: Responsive Web Design

FONTS

Page 44: Responsive Web Design

What About Fonts?

• EMS– The “em” is a scalable unit that is used in web

document media.– 1em is equal to the current font-size of the element

in question– If you haven't set font size anywhere on the page,

the browser default is 16px– By default 1em = 16px– If you set a font-size of 20px on your body,

then 1em = 20px

Page 45: Responsive Web Design

EM = Target / Context

• Default: 16px• Target: 8px• EM = 8/16 = 0.5em

Page 46: Responsive Web Design

Example

Page 47: Responsive Web Design

IMAGES

Page 48: Responsive Web Design

Flexible Images

• Images width can also be defined in %

• Setting the max-width to 100% also ensures that the image does not scale larger than its actual size

Page 49: Responsive Web Design

Downloaded vs. Displayed

Page 50: Responsive Web Design

High/low resolution

Page 51: Responsive Web Design

High/low resolution

Page 52: Responsive Web Design

Responsive Image Solutions

• Possible solutions– Picturefill

• A polyfill script for the proposed Html5 <picture> element

– HiSRC• A plugin that enables you to create low-, medium- and

high-resolution versions of an image, and the script will show the appropriate one based on Retina-readiness and network speed.

Page 53: Responsive Web Design

Picturefill Implementation

Page 54: Responsive Web Design

Css3

Page 55: Responsive Web Design

Media Queries

• CSS3 module

• A media query is an expressions, which resolves to either true or false

• When a media query is true, the corresponding style rules are applied

Page 56: Responsive Web Design
Page 57: Responsive Web Design

Media Types

• @media screen

• Recognized media typesall, braille, embossed, handheld, print, projection, screen, speech, tty, tv.

Page 58: Responsive Web Design

• (min-|max-)width and (min-|max-)height These allow us to query the width and height of the viewport (i.e. the browser window)

• Orientation:– Landscape– Portrait

Page 59: Responsive Web Design

Ipad - Portrait

Page 60: Responsive Web Design

Iphone - Landscape

Page 61: Responsive Web Design

BROWSER COMPATIBILITY

Page 62: Responsive Web Design

Browser CompatibilityIE 9, 10 IE 6, 7, 8

Opera 9.5+ Opera Mobile

Safari 3+ Safari 2

Firefox 3.5 Firefox 1, 2

Chrome

Page 63: Responsive Web Design

• Write css for desktop browsers – the way you always did

• Use media queries to optimize for smaller mobile screens

• Using this workflow, older IE’s will always show the desktop version

Possible solution

Page 64: Responsive Web Design

Problem

• Not all of us browse the web using the latest mobile devices

• There are lots of older, popular and less capable devices around that don’t support media queries

• Using this workflow means these devices won’t show our mobile layout

Page 65: Responsive Web Design

MOBILE FIRST

Page 66: Responsive Web Design

Mobile First• start with a fluid mobile layout• use media queries to optimize for bigger

screens

• This way, all devices are served a mobile layout at first

• Meaning even devices that don’t support media queries will display the mobile version of your website

Page 67: Responsive Web Design

• Most desktop browsers understand media queries so they’ll serve the desktop layout.

• But what about older IE versions?– The layout will be broken but the content will still

be readable.

Page 68: Responsive Web Design

Polyfills

• You can use a polyfill– Which forces older IE versions to interpret media

queries.

• Polyfill– Downloadable code which provides facilities that

are not built into a web browser. – It implements technology that a developer

expects the browser to provide natively.

Page 69: Responsive Web Design

Polyfills

Page 70: Responsive Web Design

Browser CompatibilityIE 9, 10 IE 6, 7, 8

Opera 9.5+ Opera Mobile

Safari 3+ Safari 2

Firefox 3.5 Firefox 1, 2

Chrome

Page 71: Responsive Web Design

JS

Page 72: Responsive Web Design

JS

• Browser detection

• Jquery: jQuery.browser – deprecated

• Js : User Agent: navigator.userAgent

Page 73: Responsive Web Design

User Agent

Page 74: Responsive Web Design

META TAGS

Page 76: Responsive Web Design

Now let’s see how that looks on mobile…

Page 77: Responsive Web Design

• iOS Safari assumes a webpage is 980px wide, zooming out in order to fit the whole lot within the available (iPhone 4) 320px.

• The content is then much less readable, unless you zoom in.

Page 78: Responsive Web Design

Viewport

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

• For example, if your mobile design is purposely laid out at 320px you can specify the viewport width:

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

Page 79: Responsive Web Design

• For flexible layouts it’s more practical to base your viewport width on the device in question, so to match your layout width to the device width you’d enter:

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

Page 80: Responsive Web Design

• To be extra certain that your layout will be displayed as you intended it you can also set the zoom level. This, for example:<meta name="viewport" content="initial-scale=1">

• This will ensure that upon opening, your layout will be displayed properly at 1:1 scale.

• No zooming will be applied. You could even go further and prevent any zooming by the user:<meta name="viewport" content="maximum-scale=1">

Page 81: Responsive Web Design

TESTING

Page 82: Responsive Web Design

Testing…

• 2 main components:• Screen size• User Agent emulation

• Chrome Plugins:– Mobile/RWD Tester – user agent + screen size

• Chrome Emulator

Page 83: Responsive Web Design

BOOKS

Page 84: Responsive Web Design

Books

Ben Frain Tim Kadlec

Page 85: Responsive Web Design