Responsive Day Out: What's next in StandardsLand?

Bruce Lawson Opera Software

Responsive Day Out: What's next in StandardsLand?

Bruce Lawson

lots of devices, tablets, phones
http://www.flickr.com/photos/brad_frost/7387827018/in/set-72157630163121422

Opera Software

Remapping physical and virtual pixels

screenshot of Mac utility to change screen resolution

980px

Samsung Galaxy SII, Opera, "Browser", Chrome, Firefox, QQ Browser, Maxthon, UCWeb HD, Baidu, Dolphin all default to 980px in absence of viewport meta.

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

<meta name="viewport"
 content="width=320, 
 user-scalable=no">
Apple's documentation
karen lauke's website, 550 pixels wide, centered on a desktop machine
karen lauke's website, 550 pixels wide, centered on a  mobile, so hard to read

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

karen lauke's website, 550 pixels wide, filling a mobile screen

Rule of thumbs

If you're using Media Queries, use
<meta name="viewport"
content="width=device-width">
If your site has an explicit width, eg 550px:
<meta name="viewport" content="width=550">
chinese food stand with spiders, centipedes, sheep penis, water beetles for sale

Problems with viewport meta

We demand better
than viewport meta!

web developers looking all heavy rock
Photographer: Joby Sessions jobysessions.com
css device adaptation

CSS Device Adaptation

@viewport {
  width: 320px;
  zoom: 2.3;
  user-zoom: fixed;};

Prefixed: Opera Presto, IE10. WebKit support beginning

min and max width

@-o-viewport {
    /* minimum of 550px viewport width */
    width: 550px auto; max-zoom: auto;
}
devO: Introduction to meta viewport and viewport

The minimum width the page can be is 550px. So, if your physical width is less than 550 physical pixels, map this page's 550px width to whatever your real width is so it fills the page.

However, if you are more than 550 physical pixels wide, don't remap; put the 550px in the middle of the 980 pixels (which is the standard viewport width), and produce margins each side of (980 -550) / 2 (= 115 px). Please.

tablet and phone dispays side-by-side; tablet has borders, phone fills up full screen

Windows tablet snap mode


@media only screen and (max-width: 400px) {
 @-ms-viewport { width: 320px; }
 }
mobilexweb.com
Riotously colourful surreal image to ilustrate flexbox

Beware 2009, 2011 syntaxes

  1. a box-{*} property
  2. display: box;
  3. display: flexbox;
  4. flex() property
css-tricks.com/old-flexbox-and-new-flexbox/

Easy vertical centering

<style>
 div {display:flex; height:500px;} 
 article {margin:auto;}
</style>

<div>
<article>hello</article>
</div>
box vertically and horizontally centered within another

Lining up boxes

section {display: flex; flex-flow: row;}

<section>
 <article id="first">#first</article>
 <article id="second">#second</article>
 <article id="third">#third</article>
</section>
3 boxes lined up in a row

Aligning items

section {display: flex;
flex-flow:row;
align-items: center;}
3 boxes lined up in a row. centered on vertical axis

Flexibility

#first {flex: 1;}
#second {flex: 1;}
#third {flex: 1;}
3 boxes lined up in a row. centered on vertical axis, each the same width

Flexibility

#first {flex: 1;}
#second {flex: 1;}
#third {flex: 2;}
3 boxes lined up in a row. centered on vertical axis, the last wider than the previous 2

justify-content

Flexbox — fast track to layout nirvana? http://bit.ly/UOGnWf
3 boxes lined up in a row. centered on vertical axis, the last wider than the previous 2

Re-ordering content

#second {order: 1;}
#first {order: 2;}
#third {order: 3;}
The second box is now moved into the first position
fix my street.com screenshot

Filthy hack

@media screen and (max-width: 480px) {
	body {display: table;
	caption-side: bottom;}
    
	nav  {float: none;
	display: table-caption;
	width:100%;}
}
media queries level 4

script Media Query

@media screen and (script) {…}

@media screen and not (script) {…}

hover Media Query

The ‘hover’ media feature is used to query whether primary pointing system used on the output device can hover or not.

@media screen and not (hover) {…}

pointer Media Query

@media (pointer:coarse) {
  input[type="checkbox"], input[type="radio"]
    {min-width:30px; min-height:40px;}
}

Choices are coarse, fine, none.

@media (paged) and (interactive:0) 
	{ /* I am like a printer */ }

@media (paged) and (interactive)
	{ /* I'm a projector, or like a Kindle */ }

@media (paged) and (interactive) and (touch) 
	{ /* I'm like a touch-screen Kindle */ }
@media (touch) and (keyboard) and (min-width:600) 
    { /* looks like a touch-screen laptop */ }

@media (remote) 
    { /* TV or set-top box? */ }

 @media (remote) and (hover) 
    { /* like a Wii? */ }
smartphone and 50 inch TV at natural distances from viewer: smartphone is 'bigger' screen than TV
Pointer Events spec

Pointer Events

A pointer is a hardware agnostic representation of input devices that can target a specific coordinate (or set of coordinates) on a screen.
diagram showing pen, touch and mouse are all pointers

Pointer Events API

The events for handling generic pointer input look a lot like those for mouse: pointerdown, pointermove, pointerup, pointerover, pointerout, etc. This facilitates easy content migration from Mouse Events to Pointer Events.

http://smus.com/mouse-touch-pointer/

Pointer Events provide all the usual properties present in Mouse Events (client coordinates, target element, button states, etc.) in addition to new properties for other forms of input: pressure, contact geometry, tilt, etc. So authors can easily code to Pointer Events and their content just works no matter what input hardware is being used.
woman on phone saying 'if I use a low-res image it looks bad in high-dip big-screen devices. If I use high-res images, I might waste visitor's bandwidth. Adaptive images!
a logo

Scalable Vector Graphics

Media Queries in SVG

Note: MQs are in CSS inside SVG so are carried with it - no need to change site's CSS at all.

Read more on this technique (invented by Andreas Bovens - in 2009!)

Inside the SVG file

	@media screen and (max-width: 256px)
	{
	#circle1 {stroke-width: 10px;}
	#spiral {display: none;}
	}

WebP

WebP lossless images are 26% smaller in size compared to PNGs. WebP lossy images are 25-34% smaller in size compared to JPEG images

background images fallback

CSS Image Values and Replaced Content Module Level 4

background-image: url("wavy.png");
background-image: image("wavy.webp", "wavy.png");
	

What about content images?

HTML5 video

<video>
	<source src=foo.webm type=video/webm>
	<source src=foo.mp4 type=video/mp4>
	  <!-- Fallback content -->
</video>

HTML.next <picture>

<picture>
	<source src=foo.webp type=image/webp>
	<source src=foo.png type=image/png>
	  <!-- Fallback content -->
</picture>
me and Matt 'Wilto' Marquis

HTML5 video with Media Queries

<video>
<source src=foo-hires.webm>
<source src=foo-lowres.webm media="max-width:480px">
  <!-- Fallback content -->
</video>

HTML5.next <picture> with art direction

<pocture>
<source src=foo-full.webp>
<source src=foo-clipped.webp media="max-width:480px">
  <!-- Fallback content -->
</picture>
art directed images on variety of devices
responsive images community group

Thanks

  • Bruce and Wilto by Geri Coady @hellogeri
  • SVG/ Media Queries by Andreas Bovens @andreasbovens
  • Inspiration for W3C spec logos: Aral Balkan @aral
  • HTML/ CSS Presentation Framework: Shower by Vadim Makeev.