responsive content

95
Responsive content CSS Dev Conference Hans Sprecher | @honzie

Upload: honzie

Post on 10-Jun-2015

857 views

Category:

Technology


0 download

DESCRIPTION

Responsive Content deck from CSS Dev Conf.

TRANSCRIPT

Page 1: Responsive content

Responsive contentCSS Dev Conference

Hans Sprecher | @honzie

Page 2: Responsive content

Responsive designfascinating.

Page 3: Responsive content

Respond to capabilities

• Screen size

• Browser sophistication

• Device features

Page 4: Responsive content

Contentas responsive as the design.

Page 5: Responsive content

Mobile site

Page 6: Responsive content

Responsive web

Page 7: Responsive content

We can do better

Page 8: Responsive content

3LazyLoad

1Prune

2Link

Page 9: Responsive content

3LazyLoad

1Prune

2Link

Page 10: Responsive content

Pruning content

• Good for secondary content

• Potentially dangerous

• No Full site link

Page 11: Responsive content

Secondary content pruning

Page 12: Responsive content
Page 13: Responsive content

Image pruning

Page 14: Responsive content

Image pruning

Page 15: Responsive content

Consider removing completely

Page 16: Responsive content

Mobile site vs. full site

• Cut features

• Cut content

• Enlarge UI

Page 17: Responsive content

Josh Clark, @globalmoxie

http://www.netmagazine.com/opinions/nielsen-wrong-mobile

Page 18: Responsive content

Like publishing a paperback with chapters missing.

Page 19: Responsive content

Like publishing a movie in fullscreen on VHS.

Page 20: Responsive content

Prune fodder

• Testimonials & quotes

• Pull quotes

• Tertiary sidebars

• Stock photos

Page 21: Responsive content

Aggressive pruning

Page 22: Responsive content
Page 23: Responsive content

“Create a retail app.”

Page 24: Responsive content
Page 25: Responsive content

“What could possibly go wrong?”

Page 26: Responsive content

Known constraints

• Known context

• Known hardware

• Support standing by

Page 27: Responsive content
Page 28: Responsive content
Page 29: Responsive content

125 lines of CSSsame HTML, JS.

Page 30: Responsive content
Page 31: Responsive content

Each prune

• Questioned content

• Thought mobile first

• Without full redesign

Page 32: Responsive content

Great proof of concept

Page 33: Responsive content

Pruning HTML & CSS<aside class=“prune-mobile”> [content]</aside>

Page 34: Responsive content

Pruning HTML & CSS<aside class=“prune-mobile”> [content]</aside>

@media (max-width: 320px) {

.prune-mobile { display: none; }

}

Page 35: Responsive content

Class naming

.prune-laptop

.prune-tablet

.prune-mobile

Page 36: Responsive content

That's better

blockquote.pull

aside.tertiary

img.stock

Page 37: Responsive content

3LazyLoad

1Prune

2Link

Page 38: Responsive content

Linking to content

• Non-linear content

• Good for news feeds

• Good for homepages

Page 39: Responsive content

Two tactics

• Link to new page

• Show content within page

Page 40: Responsive content
Page 41: Responsive content

JavaScript reveals summary

Page 42: Responsive content

Reveal Link: HTML<section>

<article class=“clipped”> [content] </article>

<span class=“read-more”> Read more </span>

</section>

Page 43: Responsive content

Reveal Link: CSS & JS@media screen and (max-width:480px) {

.clipped { height: 2em; overflow: hidden; }

}

Page 44: Responsive content

Reveal Link: CSS & JS@media screen and (max-width:480px) {

.clipped { height: 2em; overflow: hidden; }

}

$(‘.read-more’).click(function () { $(this).siblings('article') .toggleClass(‘clipped’);});

Page 45: Responsive content

JavaScript reveals summary

Page 46: Responsive content

Why JS?this is CSS Dev Conference

Page 47: Responsive content

CSS Reveal: HTML<section>

<input class="toggle" type="checkbox" />

<article> [content] </article>

</section>

Page 48: Responsive content

CSS Reveal: Interaction CSS@media (max-width:480px) {

article { height: 156px; overflow: hidden; }

.toggle:checked + article { height: auto; }

}

Page 49: Responsive content

CSS Reveal: Style CSS@media screen and (max-width:480px) {

.toggle { position: absolute; right: 0; bottom: 0; display: block; }

.toggle::after { content: 'Read more'; }

.toggle:checked::after { content: 'Read less'; }

}

Page 50: Responsive content

CSS reveals summary

http://www.hanssprecher.com/css-tray.html

Page 51: Responsive content

Can I use CSS3 Selectors?

Page 52: Responsive content

Can I use CSS3 Selectors?Yes! *Except for Safari 3.1

Page 53: Responsive content

CSS Tabs

http://www.hanssprecher.com/css-tabs.html

Page 54: Responsive content

CSS Tabs: HTML<section>

<ol> <li><a href="#tab1">Tab 1</a></li> <li><a href="#tab2">Tab 2</a></li> </ol>

<article id="tab1"> [content] </article>

<article id="tab2"> [content] </article>

</section>

Page 55: Responsive content

CSS Tabs: Interaction CSS@media (max-width:480px) {

article { display:none; }

article:target { display:block; }

}

Page 56: Responsive content

CSS Tabs

http://www.hanssprecher.com/css-tabs.html

Page 57: Responsive content
Page 58: Responsive content

Metro

Page 59: Responsive content

With little CSS & JScomes great power.

Page 60: Responsive content

Read the spec

Page 61: Responsive content

<aside>

“content that is tangentially related to the [main textual] content”

Page 62: Responsive content

<figure>

“a unit of content [...] that is self-contained [...] and that can be moved [...] without

affecting the document’s meaning”

Page 63: Responsive content

3LazyLoad

1Prune

2Link

Page 64: Responsive content

Lazy loading

• Linear content

• Good for articles

• Quicker initial load

Page 65: Responsive content

Ready, set, go!

Page 66: Responsive content

80% fasterto DOM ready.

Page 67: Responsive content

Page load HTML<aside id=“lazy-images”> <img> <img></aside>

Page 68: Responsive content

AJAX call<script>$(document).ready(function () { $.get(‘images.html’, function (content) { $(‘#lazy-images’).append(content); });});</script>

Page 69: Responsive content

3 Tips

Page 70: Responsive content

1. Use JSON in response

Page 71: Responsive content

[{“src”: “/earth.jpg”, “alt”: “Earth”},{“src”: “/sky.jpg”, “alt”: “Sky”},

{“src”: “/water.jpg”, “alt”: “Water”}]

Page 72: Responsive content

2. Use HTML for content

Page 73: Responsive content

<h1>Blog Post</h1>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>

<ul> <li>Ut enim ad minim</li> <li>Quis nostrud exercitan</li></ul>

Page 74: Responsive content

3. Cache the AJAX response

Page 75: Responsive content

$.ajaxSetup({cache: true});

Done by default for $.get()

Page 76: Responsive content

All together now

Page 77: Responsive content

3LazyLoad

1Prune

2Link

Page 78: Responsive content

Desktop

Page 79: Responsive content

Portrait tablet

Page 80: Responsive content

Smartphone

Page 81: Responsive content
Page 82: Responsive content

Tweak content strategyfor the device.

Page 83: Responsive content

Media queries now

Page 84: Responsive content

Current support: desktop

First Supported• IE 9

• FireFox 3.5

• Chrome 4

• Safari 3.1 / 4.0

• Opera 9.5

Current Version• IE 10

• FireFox 17

• Chrome 23

• Safari 6

• Opera 12.1

Page 85: Responsive content

Version numbers

Chrome 23 FireFox 17

Page 86: Responsive content

Version numbers

I do not think it meanswhat you think it means.

Page 87: Responsive content

Capability detectionmore important than ever.

Page 88: Responsive content

Current support: mobile

First Supported• iOS Safari 3.2

• Android 2.1

• Opera Mini 5 / 6

• Opera Mobile 10

• WP 7.5

Current Version• iOS Safari 5.0

• Android 4.0

• Opera Mini 5-7

• Opera Mobile 12

• WP 8

Page 89: Responsive content

83% global supportDecember 2012, StatCounter, Global Stats

Page 90: Responsive content

IE8

• No media query supportis the first media query

• Site should be functional

Page 91: Responsive content

Device landscapeunlikely to get simpler.

Page 92: Responsive content

Future friendlyresponsive design, responsive content.

Page 93: Responsive content

Mobile contentMobile only Responsive

Page 94: Responsive content

3LazyLoad

1Prune

2Link

Page 95: Responsive content

Thank you.

Hans Sprecher | @honzie