responsive design and jquery mobile

30
Responsive Design with jQuery Mobile 17 July 2013 Wednesday, July 17, 13

Upload: troy-miles

Post on 08-May-2015

2.895 views

Category:

Technology


2 download

DESCRIPTION

"Mobile First!", is the new cry of web designers worldwide. But how do you do it? Do you have to scrap all of your current web skills? Is it magic created by wizard-like designers which could never be understood by mere mortals? Believe it or not with the combination of jQuery Mobile and CSS3 Media Queries, you can easily create a site which looks good on phone, tablet, or desktop. In this talk, I will show how to build a simple responsively designed web site using jQuery Mobile version 1.3.1. I will begin with a design for mobile, expand it to support tablet in both landscape and portrait modes, and finally show how to take advantage of the desktop's big screen. We will also discuss some of the pitfalls of responsive design and potential work-arounds for them.

TRANSCRIPT

Page 1: Responsive Design and jQuery Mobile

Responsive Design with jQuery Mobile

17 July 2013

Wednesday, July 17, 13

Page 2: Responsive Design and jQuery Mobile

Want more? Follow me for more tutorials and source code.@therockncoder

Wednesday, July 17, 13

Page 3: Responsive Design and jQuery Mobile

Check out my videos:www.youtube.com/rockncoder

Wednesday, July 17, 13

Page 4: Responsive Design and jQuery Mobile

Source code for my tutorials hosted on GitHub @

https://github.com/Rockncoder

Wednesday, July 17, 13

Page 5: Responsive Design and jQuery Mobile

Please Rate This Talk! http://spkr8.com/t/23671

Wednesday, July 17, 13

Page 6: Responsive Design and jQuery Mobile

What We Will Cover

• What is responsive design?

• Meta tags and viewports

• Media Queries

• jQuery Mobile Responsive Design Features

• Best Practices

• Summary

Wednesday, July 17, 13

Page 7: Responsive Design and jQuery Mobile

What is Responsive Design?

Responsive web design (RWD) is a web design approach aimed at crafting sites to provide an optimal viewing experience—easy reading and navigation with a minimum of resizing, panning, and scrolling—across a wide range of devices (from desktop computer monitors to mobile phones).

Wednesday, July 17, 13

Page 8: Responsive Design and jQuery Mobile

Meta Tags

• They always go in the <head> section

• They are never displayed

• They consist mostly of key/value pairs

• They are data about data

Wednesday, July 17, 13

Page 9: Responsive Design and jQuery Mobile

The Viewport

• A special type of meta tag which defines the screen of a mobile device

Wednesday, July 17, 13

Page 10: Responsive Design and jQuery Mobile

The Viewport

Wednesday, July 17, 13

Page 11: Responsive Design and jQuery Mobile

The Viewport

1 <!DOCTYPE html> 2 3 <html> 4 <head> 5 <title>Module 1</title> 6 <meta charset="utf-8"/> 7 <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/> 8 <meta name="apple-mobile-web-app-capable" content="yes"/> 9 </head>

Wednesday, July 17, 13

Page 12: Responsive Design and jQuery Mobile

Viewport Attributes

• width=device-width - converts the pixels to CSS pixels

• initial-scale=1 - sets the scale level

• user-scalable=no - turns off scaling

Wednesday, July 17, 13

Page 13: Responsive Design and jQuery Mobile

Media Query

• Begins with @media

• And has at least one expression that limits the style sheets’ scope

Wednesday, July 17, 13

Page 14: Responsive Design and jQuery Mobile

Media Query@media screen and (max-width: 1024px) and (orientation:portrait)

• the media type is screen

• the styles only defined if

• The width is 1024px or less

• AND the orientation is portrait

Wednesday, July 17, 13

Page 15: Responsive Design and jQuery Mobile

Media Query

• Can have more complex expression which are separate by:

• not - used to negate a media query

• and - used to combine multiple media features

• only - applies a style only if the entire query matches

Wednesday, July 17, 13

Page 16: Responsive Design and jQuery Mobile

Demo: Squirrels

Wednesday, July 17, 13

Page 17: Responsive Design and jQuery Mobile

jQuery Mobile Features

• Grids

• Tables

• Panels

Wednesday, July 17, 13

Page 18: Responsive Design and jQuery Mobile

Grids

• Consists of two parts

• A div which serves as the container for the columns

• Divs which are the individual columns

Wednesday, July 17, 13

Page 19: Responsive Design and jQuery Mobile

Grids

• On the root div ui-grid-x class is applied

• ui-grid-a = 2 columns

• ui-grid-b = 3 columns

• ui-grid-c = 4 columns

• ui-grid-d = 5 columns

Wednesday, July 17, 13

Page 20: Responsive Design and jQuery Mobile

Grids

• Each column has the class ui-block-x applied

• The class must be in correct alphabetic order or the universe will cease to exist

• ui-block-a, ui-block-b, ui-block-c, etc

Wednesday, July 17, 13

Page 21: Responsive Design and jQuery Mobile

Demo: Grids

Wednesday, July 17, 13

Page 22: Responsive Design and jQuery Mobile

Tables

• Two types of tables:

• Reflow

• Column Toggle

• Only difference in the markup is the data-mode attribute

Wednesday, July 17, 13

Page 23: Responsive Design and jQuery Mobile

Demo: Fun with Tables

Wednesday, July 17, 13

Page 24: Responsive Design and jQuery Mobile

Panels

• A hidden page which reveals itself by sliding from the left or right onto the page

• Must precede the header section

Wednesday, July 17, 13

Page 25: Responsive Design and jQuery Mobile

Demo: Panels

Wednesday, July 17, 13

Page 26: Responsive Design and jQuery Mobile

Best Practices

• Design styles beginning with "mobile first", then go wider

• Use "min-width" to constrain styles

• Prefer percentages and ems to pixels

Wednesday, July 17, 13

Page 27: Responsive Design and jQuery Mobile

Other Options

• Twitter Bootstrap

• Foundation

• Skeleton

• http://responsive.vermilion.com/compare.php

Wednesday, July 17, 13

Page 30: Responsive Design and jQuery Mobile

Summary

• It is easy to get started with responsive web site design with jQuery Mobile

• It requires a lot of planning to get it right

• There may be better tools for your site’s needs

Wednesday, July 17, 13