html 5 mobile - nitty gritty

83
HTML 5 Mobile Nitty-Gritty

Upload: marionoble

Post on 13-May-2015

602 views

Category:

Technology


0 download

DESCRIPTION

An overview of some HTML 5 best practices and tools for mobile / Universal Design.

TRANSCRIPT

Page 1: Html 5 mobile - nitty gritty

HTML 5 Mobile Nitty-Gritty

Page 2: Html 5 mobile - nitty gritty

Who the heck are you?● web designer● front end developer

"integrator"● over ten years of

experience● freelance/ company /

small and enterprise● principal at Context

Multimedia and Mario Noble Design

● organizer SCWDD

Mario Noble

Page 3: Html 5 mobile - nitty gritty

What this is and isn'tThis is a medium dive into "HTML 5" practices for mobile.

This isn't comprehensive guide to everything mobile/HTML5 nor a guide on native mobile app development. HTML5 = new Web 2.0?

Page 4: Html 5 mobile - nitty gritty

Goals

● Give a mental model and context

● Show/tour a basic version in action

● Act as a guide to starting points for research

● Inspire people to get going or to be advocates for a Universal approach

Page 5: Html 5 mobile - nitty gritty

A start to getting it done.

Page 6: Html 5 mobile - nitty gritty

Agenda

● Overview - General tour of a typical page● Gritty Tips and Tricks.● Some useful tools and plugins● Summary● Q&A

10-20 minutes each

Page 7: Html 5 mobile - nitty gritty

High level overview

Page 8: Html 5 mobile - nitty gritty

Why are we doing it?

Usability, Usefulness and Relevancy

Page 9: Html 5 mobile - nitty gritty

It's not just about mobileIt's about Universal Design

Page 10: Html 5 mobile - nitty gritty

Design for all

Even this guy.

Page 11: Html 5 mobile - nitty gritty

Dovetailswith Accessibility

Not just political correctness

Page 12: Html 5 mobile - nitty gritty

We're all now disabled sometimes

● need scalable text● low bandwidth● contrast problems● video captioning

● unclear interfaces● difficult data entry● cognitive overload● coordination issues

Page 13: Html 5 mobile - nitty gritty

Warning: Cliches ahead!

● Less is More. ● Form follows Function. ● In Crisis, Opportunity. ● KISS

Page 14: Html 5 mobile - nitty gritty

PrioritiesLimitations, Constraints and Boundaries...oh my!

Page 15: Html 5 mobile - nitty gritty

Lamp versus Laser focus

Page 16: Html 5 mobile - nitty gritty

UD is both a narrowing and broadening opportunity

When one door closes, a window opens.

Page 17: Html 5 mobile - nitty gritty

Beware of one size fits all.

Page 18: Html 5 mobile - nitty gritty

The difference between a site and an app

general orientation task oriented

Page 19: Html 5 mobile - nitty gritty

Sometimes these blur...

Page 20: Html 5 mobile - nitty gritty

A little nitty grittyShared approaches and differences

Page 21: Html 5 mobile - nitty gritty

Some context...General ElementsStructure AdaptationCapabilityPolyfilling/ FallbacksPerformanceTesting

Tech SpecificsHTMLJSCSSFrameworksPluginsServer side

Page 22: Html 5 mobile - nitty gritty

Shared approaches

● Progressive enhancement● Scaling content● "Fat finger design"● Contextual Adaptation (geo, time, offline

access, web workers)● Gestures● PNGs● Utilizing CSS3 and HTML 5 over JavaScript● Image sprites

Page 23: Html 5 mobile - nitty gritty

Differing approaches

● Desktop polyfill support● HTML5 / CSS 3 support● Explicit permissions● App store limits● Vectors (SVG and Canvas)● Webfonts● Splash screens● Security● Form elements

Page 24: Html 5 mobile - nitty gritty

Various custom methods

Mobile Templates

ResponsiveDesign

JavaScriptTweaks

Page 25: Html 5 mobile - nitty gritty

Mobile TemplatesMay be user agent sniffing dependent

Page 26: Html 5 mobile - nitty gritty

JavaScript TweaksVarious options

Page 27: Html 5 mobile - nitty gritty

Responsive DesignNeeds CSS3 media queries

Page 28: Html 5 mobile - nitty gritty

I prefer Responsive Design

But sometimes it's almost a religious debate...No one says you can't mix and match.

Page 29: Html 5 mobile - nitty gritty

Quick tour!Let's leave these slides for a bit...

Page 30: Html 5 mobile - nitty gritty

Whew!...we're back to the slides.

Page 31: Html 5 mobile - nitty gritty

Tips and TricksLet's get a little dirty.

Well, not that dirty...

Page 32: Html 5 mobile - nitty gritty

Let's Start!We'll focus on Content, Presentation and Behavior

Page 33: Html 5 mobile - nitty gritty

Content

Page 34: Html 5 mobile - nitty gritty

Viewport meta tagInclude in your HEAD<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta name="viewport" content="initial-scale=1, maximum-scale=1">used for iOS landscape/portrait fix - prevents user zoom though

good reference on Mozilla Dev Network

Page 35: Html 5 mobile - nitty gritty

@media breakpoints and ranges@media (min-width: 800px) { ... }@media tv (min-width: 800px) { ... }@media all and (max-width: 599px) {...}@media (min-width: 800px) and (orientation: landscape) { ... }@media all and (min-width: 481px) and (max-width: 799px) {...}A "mobile first" /LCD approach helps a lot!Other parameters sometimes supported: aspect ratio, resolution, monochrome

See MDN

Page 36: Html 5 mobile - nitty gritty

Flip it good@media screen and (orientation:portrait) { /* Portrait styles */}

@media screen and (orientation:landscape) { /* Landscape styles */}Can be used to target iOS devices along with their width as well.

Page 37: Html 5 mobile - nitty gritty

@media queriesBringing them inIndividual stylesheets: <link rel='stylesheet' media='screen and (min-width: 801px) and (max-width: 961px)' href='css/medium.css' />Or embed inlineOr @import into parent stylesheetexample: @import url(red.css) (min-width:400px);

Best method: use @media in main stylesheets and/or bring in during compile with preprocessors. Centralizes styles and reduces http requests

Page 38: Html 5 mobile - nitty gritty

HTML5 tags and ARIA roles<HEAD><NAV><SECTION><ARTICLE><ASIDE><FOOTER><HGROUP>

Needs Shiv for IE < 9

role="banner"role="navigation"role="main" (new!)role="complementary"role="search"role="contentinfo"use instead of a classheader[role="banner"] { }

Page 39: Html 5 mobile - nitty gritty

Scalable imagesimg {max-width: 100%; }img {max-width: 100% !important; }img {max-width: 100%; border-width: 0; vertical-align: middle; -ms-interpolation-mode: bicubic; height: auto;}

Additional bandwidth friendly options:Filament Group, Adaptive, Picturefill

Page 40: Html 5 mobile - nitty gritty

HTML VideoToo complex to go over here.Use something like fitvids.js for scaling third party embedded videos.

Useful resources if you want to roll your own:https://developer.mozilla.org/en-US/docs/HTML/Element/videohttp://diveintohtml5.info/video.html

Page 41: Html 5 mobile - nitty gritty

Normalization vs. Reset StylesProcessing overload vs maintenance

Page 42: Html 5 mobile - nitty gritty

Presentation

Page 43: Html 5 mobile - nitty gritty

"Fat finger" touch guidelines28 pixels to 72 pixels

Page 44: Html 5 mobile - nitty gritty

Pixels and remsFont-size can be pixels for IE < 9 and rems (root em) for everyone else Root base size 14pxexample:.main-navigation {

font-size: 11px;font-size: 0.785714286rem; /* 11/14 */

}

Page 45: Html 5 mobile - nitty gritty

Beware of display:noneMany people think if they use display:none on an element in css, the background won't load. This is often wrong.Great breakdown on timkadlec.comThere are ways:1. display:none on the parent element2. display:none within media queries

Not absolutely consistent in Fennec browser.

Page 46: Html 5 mobile - nitty gritty

RGB and RGBAdiv {background: #c83636;background:transparent; filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#50990000,endColorstr=#50990000); zoom: 1;background: rgb(200, 54, 54); background: rgba(200, 54, 54, 0.5); }

Page 47: Html 5 mobile - nitty gritty

Multiple backgrounds#exampleA {width: 500px;height: 250px;background-image: url(decoration.png), url(ribbon.png), url(old_paper.jpg);background-repeat: no-repeat;background-position: left top, right bottom, left top;}

courtesty of CSS3.info

Page 48: Html 5 mobile - nitty gritty

CSS Background sizingbackground-size: 200px;background-size: 200px 100px;background-size: 200px 100px, 400px 200px;background-size: auto 200px;background-size: 50% 25%;background-size: contain;background-size: cover;

courtesy of CSS3.info

Page 49: Html 5 mobile - nitty gritty

Grids

You can still use the 960 grid. However, you may want to consider designing in 300px "chunks" for easy linearization on small screens.

320andup can use a 4 column layout which covers many situations.

Page 50: Html 5 mobile - nitty gritty

Rounded corners and shadows!

#somediv {-moz-border-radius: 18px;border-radius: 18px;box-shadow: 20px 20px 10px #CCC;text-shadow: 1px 1px 1px #000;}

Page 51: Html 5 mobile - nitty gritty

CSS Gradientsbackground: #1e5799; /* Old browsers */background: -moz-linear-gradient(left, #1e5799 0%, #2989d8 50%, #207cca 51%, #7db9e8 100%); /* FF3.6+ */background: -webkit-gradient(linear, left top, right top, color-stop(0%,#1e5799), color-stop(50%,#2989d8), color-stop(51%,#207cca), color-stop(100%,#7db9e8)); /* Chrome,Safari4+ */background: -webkit-linear-gradient(left, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* Chrome10+,Safari5.1+ */background: -o-linear-gradient(left, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* Opera 11.10+ */background: -ms-linear-gradient(left, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* IE10+ */background: linear-gradient(to right, #1e5799 0%,#2989d8 50%,#207cca 51%,#7db9e8 100%); /* W3C */filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#7db9e8',GradientType=1 ); /* IE6-9 */

Argh!

Page 52: Html 5 mobile - nitty gritty

CSS Gradients Cont.

Make your life easier. Use Colorzilla's gradient generator, a preprocessor mixin or another tool:http://www.colorzilla.com/gradient-editor/

Page 53: Html 5 mobile - nitty gritty

Getting your percentageTry to use percentages on columns for better scalability.

For Example:

@media tv (min-width: 1024px) { #container {width:960;}

}

#mainContent {width: 60%;}#sidebar{width: 40%;}

Page 54: Html 5 mobile - nitty gritty

Transitions, Transforms and AnimationUse them instead of JavaScript animations when possible for better performance on mobile devices. Provide fallback for older desktop environments when necessary.Good resource: http://www.css3maker.com/

Example Transform:#footer h1:focus { transform: translate(45px, -45px); }works for scale, skew, rotate

Transitions properties over time:#footer h1:focus { transition: color 0.2s ease-out;}

Page 55: Html 5 mobile - nitty gritty

Transitions, Transforms and Animation cont.Animate over keyframes:

@webkit-keyframes 'appear' {0% { opacity : 0; }100% {opacity: 1;}

}

.someAnimTarget { -webkit-animation: 'appear' 300ms ease-in 1 alternate 5s forwards}

As usual, keep in mind browser prefixs -web, -o, -moz

Page 56: Html 5 mobile - nitty gritty

Floats and fixed

Complex floating doesn't always play well with mobile/UD and smooth fixed positioning of items is spotty in older versions of Android.

Page 57: Html 5 mobile - nitty gritty

Behavior

Page 59: Html 5 mobile - nitty gritty

"Easy" ValidationIf creating a mobile only site/app, HTML5 has some great new form attributes for validation and finer control.

Examples: required, pattern, autocomplete, placeholder

See MDN for more examples

Page 60: Html 5 mobile - nitty gritty

Modal hellIf you're using modals don't rely on the close button. Enable close outside modal.

Page 61: Html 5 mobile - nitty gritty

No hover, but clickThere is no such thing as hover for touch

Page 62: Html 5 mobile - nitty gritty

Reduce, reduce, reduce

Do all the things you should normally do to optimize but actually do them.

Remember to minify code, gzip files, cache, CDNs, image sprites and dynamic server side image resizing where possible on production/live sites.

Page 63: Html 5 mobile - nitty gritty

GeolocationInvolves some javascript and the user's explicit permission to allow you to use their location. This also depends on their GPS and network capabilities to determine where they are.Fist detect for support using something like modernizr.js then run a query against the device.You may need a fallback

Page 64: Html 5 mobile - nitty gritty

Geolocation Cont.function get_location() { if (Modernizr.geolocation) { navigator.geolocation.getCurrentPosition(show_map); } else { // this device isn't supporting it }}

Try geolocation.js for fallback alternative.

Page 65: Html 5 mobile - nitty gritty

Caching<html manifest="/yourcache.manifest">

In that file:

CACHE MANIFEST# rev 54myscript.jscss/mycss.css

only updated when rev# changes

On Apaches set .htaccess file

AddType text/cache-manifest .manifestExpiresActive OnExpiresDefault "access"

Page 66: Html 5 mobile - nitty gritty

Other great stuff to look into.

Local StorageIcon fontsCanvas and SVG for scalable graphics

Page 67: Html 5 mobile - nitty gritty

I probably missed some thingsBut there's only so much time in an hour.

Page 68: Html 5 mobile - nitty gritty

Time to rinse off.

Page 69: Html 5 mobile - nitty gritty

Useful ToolsWhen you don't want to roll your own

Page 70: Html 5 mobile - nitty gritty

Useful HTML5 frameworks

Page 72: Html 5 mobile - nitty gritty

Polyfills/Fallbacks

Page 73: Html 5 mobile - nitty gritty

Herding Browser CatsModernizrFeature Detection and basic html tag fixesalong with Respond.js

SelectivzrMore comprehensive CSS3 support

CSS3 PIE for CSS3-like effects on IE 6-8

Page 74: Html 5 mobile - nitty gritty

Some good helpers/pluginsWarning : Your mileage may vary.

Page 76: Html 5 mobile - nitty gritty

Process and TestA few good building processors and testing tools

Page 78: Html 5 mobile - nitty gritty

There's an Appfor apps...to wrap that.

Page 80: Html 5 mobile - nitty gritty

How does this relate to me?

Page 81: Html 5 mobile - nitty gritty

Skill set takeaway● HTML5● CSS3● Preprocessors● Content/Context User

Centered approach● Progressive

enhancement attitude● Fallback planning● Willingness to Prioritize

and Test● Get in deep with a

framework

Page 82: Html 5 mobile - nitty gritty

To sum upMobile design and development can be both challenging and rewarding.

Reach more people than ever before in more contexts than ever.

The field is in flux but the reality is clear. Something needs to be done.

Page 83: Html 5 mobile - nitty gritty

Say more. Do more.

Q&A?