SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

52
Responsive Web Design, get the best of your design Frédéric Harper Technical Evangelist @ Microsoft Canada @fharper | outofcomfortzone.net SCREENS 2012

Transcript of SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Page 1: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Responsive Web Design,get the best of your design

Frédéric HarperTechnical Evangelist @ Microsoft Canada@fharper | outofcomfortzone.net

SC

REEN

S

2012

Page 2: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Sorry…

Page 3: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

How we viewed the web…• The Desktop Browser

Page 4: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

How we view the web today…• The Desktop Browser• Mobile Browsers• Tablet form-factors• Televisions• Game Consoles• More…

Page 5: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

How we view the web today…• The Desktop Browser• Mobile Browsers• Tablet form-factors• Televisions• Game Consoles• More…• So what’s the problem?

Page 6: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

The Anti-Pattern

Page 7: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Responsive Web Designs

Page 8: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design
Page 9: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Responsive Web Design

Page 10: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Responsive Web Design• Thinking of the user’s needs instead of

ours.

Page 11: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Responsive Web Design• Thinking of the user’s needs instead of

ours.• Adapt to various device capabilities instead

of configurations.

Page 12: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Responsive Web Design• Thinking of the user’s needs instead of

ours.• Adapt to various device capabilities instead

of configurations.• Help future-proof our sites.

Page 13: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

The way to go

Page 14: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Elements of Responsive Web Design• A flexible, grid-based layout,• Flexible images and media,• Media queries.• Something else.

Page 15: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Flexible, Grid-based Layout

Page 16: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Ok, so what’s the problem?• Non-responsive sites are no fun.• Fixed-width sites are not the best

experiences.• Design tools tend to use pixels.• Sometimes a pixel does not equal a pixel.• So how do we turn pixels to their em

counterparts?

Page 17: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

𝚫 𝒚𝚫 𝒙

≈ 𝐥𝐢𝐦𝒏→∞ (𝟏+𝟏

𝒏 )𝒏

×−𝒃±√𝒃𝟐−𝟒𝒂𝒄

𝟐𝒂± 𝒇 (𝒙 )=𝒂𝟎+∑

𝒏=𝟏

(𝒂𝒏𝐜𝐨𝐬𝒏𝝅 𝒙𝑳

+𝒃𝒏𝐬𝐢𝐧𝒏𝝅 𝒙𝑳 )

Pixels to Ems Algorithm

Page 18: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

target context result÷ ¿

Page 19: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

target context result÷ ¿

h1 { font-size: 24px;}

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

h1 a { font-size: 11px;}

11 / 24 = 0.458333333+

h1 a { font: 0.458333333+;}

32

Responsive Web Design READ MORE >>

1

em

%

Page 20: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

And the Grid?#page { margin: 36px auto; width: 960px;}.blog { margin: 0 auto 53px; width: 900px;}.blog .main { float: left; width: 566px;}.blog .other { float:right; width: 331px;}

#page { margin: 36px auto; width: 90%;}.blog { margin: 0 auto 53px; width: 93.75%; /* 900/960 */}.blog .main { float: left; width: 62.88+%;}.blog .other { float:right; width: 36.77+%;}

.blog { width: 900/960;}.blog .main { width: 566/900;}.blog .other { width: 331/900;}

target context result÷ ¿

Page 21: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Flexible Images and Media

Page 22: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

A Simple Solution

Works on images, as well as other media like <video>.

img { max-width: 100%;}

Page 23: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Another PossibilityFilament Group –

depends on cookies and JavaScript

Page 24: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Picture element, draft proposed

<picture width="500" height="500"><source media="(min-width: 45em)"

srcset="large-1.jpg 1x, large-2.jpg 2x"><source media="(min-width: 18em)" srcset="med-

1.jpg 1x, med-2.jpg 2x"><source srcset="small-1.jpg 1x, small-2.jpg

2x"> <img src="small-1.jpg" alt=""><p>Accessible text</p>

</picture>

Page 25: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Media Queries

Page 26: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Not so long ago…• We could define media types: screen and

print.• But not easily respond to the user’s display.• Lots of grunt work.• Didn’t spend much time thinking about

mobile devices.

Page 27: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

CSS3 Media Queries

The CSS3 Media Queries Module specifies

methods to enable web developers to scope

a style sheet to a set of precise device

capabilities.

Page 28: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Simple Example

@media screen and (max-width: 600px) { body { font-size: 80%; }}

Page 29: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Other Queries@media screen and (min-width:320px) and (max-width:480px)

@media not print and (max-width:600px)

@media screen (x) and (y), print (a) and (b)

Page 30: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Can be declared…In the StylesheetImport Rule

@import url(mq.css) only screen and (max-width:600px)

link Element

<link rel=“stylesheet” media=“only screen and (max-width:800px)” href=“mq.css”>

Page 31: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Supported Media Properties• min/max-width• min/max-height• device-width• device-height• orientation• aspect-ratio

• device-aspect-ratio• color• color-index• monochrome• resolution

Page 32: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Supported Media Properties• min/max-width• min/max-height• device-width• device-height• orientation• aspect-ratio

• device-aspect-ratio• color• color-index• monochrome• resolution

Page 33: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Little Pea Bakery

Page 34: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

What about non-supportive browsers?css3-mediaqueries-js by Wouter van der

Graaf

Just include the script in your pages

Parses the CSS and applies style for

positive media tests

Page 35: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Patterns

Page 36: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Mostly Fluid

Page 37: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Column Drop

Page 38: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Layout Shifter

Page 39: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Tiny Tweaks

Page 40: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Off Canvas

Page 41: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Resources

Page 42: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design
Page 43: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design
Page 44: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design
Page 45: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design
Page 46: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design
Page 48: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design
Page 49: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design
Page 50: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Resources• http://www.alistapart.com/articles/responsive-web-design/• http://quirktools.com/screenfly/• http://www.lukew.com/ff/entry.asp?1514• http://filamentgroup.com/examples/responsive-images/• http://code.google.com/p/css3-mediaqueries-js/• http://stuffandnonsense.co.uk/blog/about/hardboiled_css3_media_queries• http://www.stunningcss3.com/index.php• http://www.abookapart.com/products/responsive-web-design• http://www.smashingmagazine.com/2011/07/22/responsive-web-design-techniques-tools-

and-design-strategies/• http://mediaqueri.es/• http://www.w3.org/TR/css3-mediaqueries/• http://dvcs.w3.org/hg/html-proposals/raw-file/tip/responsive-images/responsive-

images.html

Page 51: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Hey, what was that 4th thing?Design• Do we start with mobile-first?• Is it best that all sites are responsive?• Do we need or want to do visual comps for every device?• Don’t dismiss mobile as walking and looking something

up.• We are at the beginning, that’s what makes this

interesting!

Page 52: SCREENS - 2012-09-28 - Responsive Web Design, get the best from your design

Questions?Frédéric Harper

[email protected]@fharper

http://webnotwar.cahttp://outofcomfortzone.net