SlideShare a Scribd company logo
1 of 68
Download to read offline
移动端Web APP开发 
CDC 设计研发中心 
miyukizhang
自我介绍 
• 张小雪 
o Miyukizhang 
o 用户研究与体验设计部 
• 重构&前端
目录 
• Web Applications? 
• HTML5 
• Web APP开发 
• 最佳实践 
• PhoneGap
目录 
• Web Applications? 
• HTML5 
• Web APP开发 
• 最佳实践 
• PhoneGap
Web Applications 
定义:Apps implemented with HTML5 
and JavaScript that operate entirely 
inside a browser.
Web App on iPhone
Web App on iPhone
案例 
http://forecast.io/ http://apps.ft.com/
Web App和Native App之争
Native App 
定义:Apps developed exclusively for 
a specific mobile platform that can 
leverage all device capabilities.
Web vs. Native 
Web Native 
Dev Cost Reasonable Expensive 
Dev Time Short Long 
Portability High No 
Performance Fast Very Fast 
Native Functionality No All 
Distribution No Yes
Hybrid App 
定义: Apps that wrap a mobile web 
interface inside a native container.
案例 
LinkedIn iPad App
Web vs. Hybrid vs. Native 
Web Hybrid Native 
Dev Cost Reasonable Reasonable Expensive 
Dev Time Short Short Long 
Portability High High No 
Performance Fast Fast Very Fast 
Native 
Functionality No Yes All 
Distribution No Yes Yes
Web vs. Hybrid vs. Native 
这个世界上,从来没有最好的技术或是编程 
语言,只有最恰当的选择和与之匹配的解决 
方案。
目录 
• Web Applications? 
• HTML5 
• Web APP开发 
• 最佳实践 
• PhoneGap
What is HTML5 
HTML5 ~= HTML + CSS3 + JS API 
详细:http://slides.html5rocks.com/#landing-slide
HTML5 for Mobile Browsers 
OS or Browser Platform Score 
(*/500) 
BlackBerry 10.1 » BlackBerry Q or Z series 485 
Opera Mobile 15 » Android 428 
Firefox Mobile 22 » Multiple platforms 422 
Chrome 25 » All Android 4 devices 417 
Opera Mobile 12.10 » Multiple platforms 406 
iOS 6.0 » Apple iPhone, iPad and iPod Touch 386 
iOS 5.0 » Apple iPhone, iPad and iPod Touch 258 
Windows Phone 8 » Nokia Lumia 822, HTC 8X and 
others 320 
Android 4.0 » Samsung Galaxy Nexus 297 
http://html5test.com/
HTML5 Elements for Mobile 
• Offline Support: Web database, 
LocalStorage, App Cache 
• Canvas 
• Video 
• GeoLocation 
• Advanced Forms 
• Workers 
• Camera
目录 
• Web Applications? 
• HTML5 
• Web APP开发 
• 最佳实践 
• PhoneGap
基本概念#1 
• CSS pixels与device pixels 
o CSS pixels: 浏览器使用的抽象单位。 
o device pixels: 显示屏幕的最小物理单位,每个dp包 
含自己的颜色、亮度。 
• 1 CSS pixels = (푑푒푣푖푐푒푃푖푥푒푙푅푎푡푖표)↑2  ∗ 
device pixels
基本概念#2 
• PPI/DPI:每英寸所拥有的像素数目 
屏幕分辨率(pixel): X*Y 
屏幕尺寸(inch): Screen Size,即手机屏幕对角线的长度 
푃푃퐼= √ 푋⁠↑2 + 푌↑2  /푆푐푟푒푒푛 푆푖푧푒 
基本概念#2 
• PPI/DPI:每英寸所拥有的像素数目 
푃푃퐼(푖푃ℎ표푛푒 4)= √ ⁠960↑2 + 640↑2  /3.5  = 330 
푃푃퐼(푖푃ℎ표푛푒 5)= √ ⁠1136↑2 + 640↑2  /4  = 326
基本概念#3 
• 密度决定比例 
ldpi mdpi hdpi xhdpi 
密度分界 120 160 240 320 
常见屏幕尺寸 240*320 320*480 480*800 640*960 
默认缩放比例 0.75 1.0 1.5 2.0
基本概念#3 
• 密度决定比例 
xxhdpi 
6% 
Android Density 
xhdpi 
25% 
hdpi 
35% 
mdpi 
23% 
tvdpi 
1% 
ldpi 
10% 
数据来源:Android Screen Sizes and Densities
Web APP开发#1 
• Small Screen CSS 
o media queries 
<link media=“only screen and (max-device-width: 480px)” 
href=“mobile.css” type=“text/css” rel=“stylesheet”/> 
<link media=“screen and (min-device-width: 481px)” 
href=“standard.css” type=“text/css” rel=“stylesheet”/>
Web APP开发#1 
• Small Screen CSS 
o media query 
@media only screen and (max-device –width: 480px){ 
#test{ 
color: red; 
} 
}
Web APP开发#2 
• UserAgent 
1. Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebkit/420.1 (KHTML, 
like Gecko) Version/3.0 Mobile/4A93 Safari/419.3 
2. Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebkit/420+ (KHTML, 
like Gecko) Version/3.0 Mobile/1A543 Safari/419.3 
3. Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebkit/ 
531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10 
Javascript: 
If((navigator.userAgent.match(/iPhone/i))){}
Web APP开发#2 
var pixelRatio = window.devicePixelRatio || 1; 
var iPhone = /iPhone/i.test(navigator.userAgent); 
var iPhone4 = (iPhone && pixelRatio == 2); 
var iPhone5 = /iPhone OS 5_0/i.test(navigator.userAgent); 
var iPad = /iPad/i.test(navigator.userAgent); 
var android = /android/i.test(navigator.userAgent); 
var webos = /hpwos/i.test(navigator.userAgent); 
var iOS = iPhone || iPad; 
var mobile = iOS || android || webos;
Web APP开发#3 
• iPhone Browser & Viewport meta 
Status Bar: 20px 
URL Bar: 60px 
Viewport: 320*356px 
Button Bar: 44px 
iPhone 
(非retina): 
320*480px
Web APP开发#3 
• Viewport Meta 
<meta name=“viewport” content=”width=device-width” />
Web APP开发#3 
• Viewport Meta 
<meta name=”viewport” content=”width=device-width, initial-scale=1.0, 
maximum-scale=1.0, user-scalable=0;”/> 
• Initial-scale=1.0: 强制让文档的宽度与设备的宽度保持1:1 
• Maximum-scale=1.0: 文档最大宽度比例是1:1 
• User-scalable=0: 不允许用户点击屏幕放大浏览
Web APP开发#4 
• Safari UI(URL Bar, Status Bar) 
<meta name=”apple-mobile-web-app-capable” content=“yes” /> 
<meta name=”apple-mobile-web-app-status-bar-style” content=“black” /> 
• JS滚动 
window.addEventListener(‘load’, function(){ 
setTimeout(function(){ window.scrollTo(0, 1); }, 100); 
})
Web APP开发#4 
• Safari UI(URL Bar, Button Bar)
Web APP开发#5 
• 主屏icon 
<link rel="apple-touch-icon" href=“apple-icon-iphone-57x57.png" /> 
<link rel="apple-touch-icon“ sizes=“72*72” href=“apple-touch-icon-72x72.png" /> 
<link rel="apple-touch-icon“ sizes=“114*114” href=“apple-touch-icon-114x114.png" /> 
<link rel="apple-touch-icon“ sizes=“144*144” href=“apple-touch-icon-144x144.png" /> 
如果图标带有 -precomposed 后缀 (如: apple-touch-icon-precomposed.png) 
• iPhone和iPod: 
o 57*57px 
o 114*114px(retina) 
• iPad: 
o 72*72px 
o 144*144px(retina) 
composed
Web APP开发#6 
• 闪屏
Web APP开发#6 
• 闪屏 
<!– iPhone --> 
<link rel="apple-touch-startup-image“ media=“(device-width:320px) and 
(device-height:480px) and (-webkit-device-pixel-ratio:1)” 
href=“apple-touch-startup-image-320x460.png" /> 
<!– iPhone4/iPhone4S--> 
<link rel="apple-touch-startup-image“ media=“(device-width: 320px) and 
(device-height: 480px) and (-webkit-device-pixel-ratio:2)” 
href=“apple-touch-startup-image-640x920.png" /> 
<!– iPhone5 --> 
<link rel="apple-touch-startup-image“ media=“(device-width: 320px) and 
(device-height: 568px) and (-webkit-device-pixel-ratio:2)” 
href=“apple-touch-startup-image-640x1096.png" />
Web APP开发#7 
• iOS中禁止用户保存图片\复制图片 
*{ -webkit-touch-callout: none; } 
• iOS中禁止用户选中文字 
*{ -webkit-user-select: none; } 
.text{ -webkit-user-select: text; } 
• iOS横竖屏字体变化 
*{ -webkit-text-size-adjust: none; }
Web APP开发#8 
• Orientation
Web APP开发#8 
• Orientation 
function checkOrientation(){ 
switch(window.orientation){ 
case 0: 
alert(‘Orientation: Portrait’); 
break; 
case 90: 
case -90: 
alert(‘Orientation: Landscape’); 
break; 
} 
} 
addEventListener(‘orientationchange’, checkOrientation);
Web APP开发#9 
• Orientation Style 
<body class="portrait"> 
window.addEventListener('load', setOrientation, false); 
window.addEventListener('orientationchange', setOrientation, false);
Web APP开发#9 
• Orientation Style 
function setOrientation() { 
var orient = Math.abs(window.orientation) === 90 ? 
'landscape' : 'portrait'; 
var cl = document.body.className; 
cl = cl.replace(/portrait|landscape/, orient); 
document.body.className = cl; 
}
Web APP开发#10 
• Touch事件 
o touchstart 
o touchend 
o touchmove 
o touchcancel 
• event对象 
o touches ( 包括pageX和pageY等 ) 
o targetTouches 
• Demo
Web APP开发#11 
• 手势( gesture事件 ) 
o gesturestart 
o gestureend 
o gesturechange 
• event对象 
o event.scale 
o event.rotate
Web APP开发#12 
• 特殊链接 
<a href="tel:12345678900">Call me</a> 
• 避免 
<meta content=”telephone=no” name=”format-detection” />
Web APP开发#13 
• Retina: background images 
.repeatingPattern { 
background: url(../images/bgPattern.png) repeat; 
background-size: 100px 100px; 
} 
@media only screen and (-webkit-min-device-pixel-ratio: 2) { 
.repeatingPattern { 
background: url(../images/bgPattern@2x.png) repeat; 
} 
}
Web APP开发#13 
• Retina: inline images 
o JS for image replacement 
if (window.devicePixelRatio === 2) { 
//Replace your img src with the new retina image 
}
Web APP开发#13 
• Retina: retina.js 
o Easy Javascript way
Web APP开发#14 
• CSS动画 
o CSS Transitions 
o CSS 2D Transformations 
o CSS 3D Transformations 
o CSS Animations 
• 效果案例 
兼容性: http://caniuse.com/
Web APP开发#14 
• CSS 3D Transformations(开启GPU加速) 
• -webkit-transform: 
o translate3d(tx,ty,tz); 
o scale3d(sx,sy,sz); 
o rotate3d(rx,ry,rz,angle); 
• Demo
Web APP开发#15 
• 调试 
o Chrome调试工具 
o weinre: Web Inspector Remote, 远程实时调试
Web APP开发#15
演示weinre
目录 
• Web Applications? 
• HTML5 
• Web APP开发 
• 最佳实践 
• PhoneGap
体验#1 
• 不要刻意模仿 iOS 的默认样式和交互 
• 不要做得像个网站 
• 块级化a标签 
o 42*42px 
• 不要自己实现滚动条 
o -webkit-overflow-scrolling: touch
体验#2 
• 模拟click事件 
o 300ms延时 
o FastClick
性能#1 
• 缩短class和id的命名 
o hd, bd, ft; 
• 慎用DataURI: 多消耗53%左右的CPU资源,内 
存多出4倍左右,耗时平均高出24.6倍 
o base64编码增加文件大小 
o 解析消耗内存和CPU 
o 无论是否缓存,重新解码
性能#2 
• Zepto.js代替 jQuery.js 
• 尽可能少的使用box-shadows与gradients 
o 扁平化设计 
• 使用3D CSS动画,即使你只需要2D的效果。 
• 避免使用opacity 
• 使用AppCache
目录 
• Web Applications? 
• HTML5 
• Web APP开发 
• 最佳实践 
• PhoneGap
What is PhoneGap 
PhoneGap is a free and open source framework 
that allows you to create mobile apps using 
standardized web APIs for the platforms you care 
about. 
http://phonegap.com/
PhoneGap的理念
PhoneGap特征 
• 开源、免费 
• 跨平台框架,支持大多主流平台 
• 基于HTML5标准,支持HTML5、CSS3和JS 
• 只写一次,到处执行 
• 支持云端编译 
• 包含丰富的API
PhoneGap APIS 
Accelerometer 
Tap into the device’s motion sensor 
Camera 
Capture a photo using the device’s camera 
Compass 
Obtain the direction that the device is pointing 
Contacts 
Work with the devices contact database 
Device 
Gather device specific information 
Event 
Hook into native events through JavaScript 
File 
Hook into native file system through JavaScript 
Geolocation 
Make your application location aware 
Media 
Record and play back auto files 
Network 
Quickly check the network state 
Notification 
Visual, audible, and tactile device notification 
Storage 
Hook into the device’s native storage options
How it work 
1.用HTML5技术写一个web App 
HTML5/CSS/JS
How it work 
2.用PhoneGap打包你的Web App
How it work 
2.用PhoneGap打包你的Web App
How it work 
3.将你的Hybrid App 
部署到各个平台 
(iOS, Android等)
End 
Thanks

More Related Content

What's hot

Creating Android Apps with PhoneGap
Creating Android Apps with PhoneGapCreating Android Apps with PhoneGap
Creating Android Apps with PhoneGapDean Peters
 
Mobile Web & HTML5 Performance Optimization
Mobile Web & HTML5 Performance OptimizationMobile Web & HTML5 Performance Optimization
Mobile Web & HTML5 Performance OptimizationMaximiliano Firtman
 
Ajax Push ICEfaces Ted Goddard
Ajax Push ICEfaces Ted GoddardAjax Push ICEfaces Ted Goddard
Ajax Push ICEfaces Ted Goddardrajivmordani
 
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)Ryan Cuprak
 
Android ActionBar Navigation reloaded
Android ActionBar Navigation reloadedAndroid ActionBar Navigation reloaded
Android ActionBar Navigation reloadedDominik Helleberg
 
Mobile Web Development with HTML5
Mobile Web Development with HTML5Mobile Web Development with HTML5
Mobile Web Development with HTML5Roy Clarkson
 
Native - Hybrid - Web Mobile Architectures
Native - Hybrid - Web Mobile ArchitecturesNative - Hybrid - Web Mobile Architectures
Native - Hybrid - Web Mobile ArchitecturesPhong Le Duy
 
Ionic - Revolutionizing Hybrid Mobile Application Development
Ionic - Revolutionizing Hybrid Mobile Application DevelopmentIonic - Revolutionizing Hybrid Mobile Application Development
Ionic - Revolutionizing Hybrid Mobile Application DevelopmentJustin James
 
HTML5 for Mobile - When and Why
HTML5 for Mobile - When and WhyHTML5 for Mobile - When and Why
HTML5 for Mobile - When and WhyDMI
 
Hybrid Mobile Application Framework
Hybrid Mobile Application FrameworkHybrid Mobile Application Framework
Hybrid Mobile Application Framework동수 장
 
Cordova + Ionic + MobileFirst
Cordova + Ionic + MobileFirstCordova + Ionic + MobileFirst
Cordova + Ionic + MobileFirstRaymond Camden
 
Intro to PhoneGap and PhoneGap Build
Intro to PhoneGap and PhoneGap BuildIntro to PhoneGap and PhoneGap Build
Intro to PhoneGap and PhoneGap BuildChris Griffith
 
Getting Started with Android - OSSPAC 2009
Getting Started with Android - OSSPAC 2009Getting Started with Android - OSSPAC 2009
Getting Started with Android - OSSPAC 2009sullis
 
Native vs Hybrid - Options to develop your mobile application
Native vs Hybrid - Options to develop your mobile applicationNative vs Hybrid - Options to develop your mobile application
Native vs Hybrid - Options to develop your mobile applicationLoic Ortola
 
Rapid mobile development with Ionic framework - Voxxdays Ticino 2015
Rapid mobile development with Ionic framework - Voxxdays Ticino 2015Rapid mobile development with Ionic framework - Voxxdays Ticino 2015
Rapid mobile development with Ionic framework - Voxxdays Ticino 2015Alessio Delmonti
 
Flash Builder and Flex Future - Multiscreen Development
Flash Builder and Flex Future - Multiscreen DevelopmentFlash Builder and Flex Future - Multiscreen Development
Flash Builder and Flex Future - Multiscreen DevelopmentRyan Stewart
 

What's hot (20)

Creating Android Apps with PhoneGap
Creating Android Apps with PhoneGapCreating Android Apps with PhoneGap
Creating Android Apps with PhoneGap
 
Hybrid Apps / iPhoneDevCon 2010
Hybrid Apps / iPhoneDevCon 2010Hybrid Apps / iPhoneDevCon 2010
Hybrid Apps / iPhoneDevCon 2010
 
Mobile Web & HTML5 Performance Optimization
Mobile Web & HTML5 Performance OptimizationMobile Web & HTML5 Performance Optimization
Mobile Web & HTML5 Performance Optimization
 
Ajax Push ICEfaces Ted Goddard
Ajax Push ICEfaces Ted GoddardAjax Push ICEfaces Ted Goddard
Ajax Push ICEfaces Ted Goddard
 
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
 
Intro to PhoneGap
Intro to PhoneGapIntro to PhoneGap
Intro to PhoneGap
 
Web app
Web appWeb app
Web app
 
Web app
Web appWeb app
Web app
 
Android ActionBar Navigation reloaded
Android ActionBar Navigation reloadedAndroid ActionBar Navigation reloaded
Android ActionBar Navigation reloaded
 
Mobile Web Development with HTML5
Mobile Web Development with HTML5Mobile Web Development with HTML5
Mobile Web Development with HTML5
 
Native - Hybrid - Web Mobile Architectures
Native - Hybrid - Web Mobile ArchitecturesNative - Hybrid - Web Mobile Architectures
Native - Hybrid - Web Mobile Architectures
 
Ionic - Revolutionizing Hybrid Mobile Application Development
Ionic - Revolutionizing Hybrid Mobile Application DevelopmentIonic - Revolutionizing Hybrid Mobile Application Development
Ionic - Revolutionizing Hybrid Mobile Application Development
 
HTML5 for Mobile - When and Why
HTML5 for Mobile - When and WhyHTML5 for Mobile - When and Why
HTML5 for Mobile - When and Why
 
Hybrid Mobile Application Framework
Hybrid Mobile Application FrameworkHybrid Mobile Application Framework
Hybrid Mobile Application Framework
 
Cordova + Ionic + MobileFirst
Cordova + Ionic + MobileFirstCordova + Ionic + MobileFirst
Cordova + Ionic + MobileFirst
 
Intro to PhoneGap and PhoneGap Build
Intro to PhoneGap and PhoneGap BuildIntro to PhoneGap and PhoneGap Build
Intro to PhoneGap and PhoneGap Build
 
Getting Started with Android - OSSPAC 2009
Getting Started with Android - OSSPAC 2009Getting Started with Android - OSSPAC 2009
Getting Started with Android - OSSPAC 2009
 
Native vs Hybrid - Options to develop your mobile application
Native vs Hybrid - Options to develop your mobile applicationNative vs Hybrid - Options to develop your mobile application
Native vs Hybrid - Options to develop your mobile application
 
Rapid mobile development with Ionic framework - Voxxdays Ticino 2015
Rapid mobile development with Ionic framework - Voxxdays Ticino 2015Rapid mobile development with Ionic framework - Voxxdays Ticino 2015
Rapid mobile development with Ionic framework - Voxxdays Ticino 2015
 
Flash Builder and Flex Future - Multiscreen Development
Flash Builder and Flex Future - Multiscreen DevelopmentFlash Builder and Flex Future - Multiscreen Development
Flash Builder and Flex Future - Multiscreen Development
 

Viewers also liked

Presentasjon1om barnehage2
Presentasjon1om barnehage2Presentasjon1om barnehage2
Presentasjon1om barnehage2ansam1234
 
Step by step milad yussefabadi
Step by step milad yussefabadiStep by step milad yussefabadi
Step by step milad yussefabadimiyussefab
 
How are you protecting your general anesthesia procedure patients from contam...
How are you protecting your general anesthesia procedure patients from contam...How are you protecting your general anesthesia procedure patients from contam...
How are you protecting your general anesthesia procedure patients from contam...Steve Koontz
 
Презентация Mobile-Asmo
Презентация Mobile-AsmoПрезентация Mobile-Asmo
Презентация Mobile-AsmoSouren M
 
给初学者的Html5教程
给初学者的Html5教程给初学者的Html5教程
给初学者的Html5教程Zhang Xiaoxue
 
The Engagement Effect Dig South
The Engagement Effect Dig SouthThe Engagement Effect Dig South
The Engagement Effect Dig SouthJohn E. Smith
 
Respiration, etc
Respiration, etcRespiration, etc
Respiration, etcJaye
 
Taller de computación básica
Taller de computación básicaTaller de computación básica
Taller de computación básicaProfesor víctor n
 
Winning The Talent War
Winning The Talent WarWinning The Talent War
Winning The Talent WarJohn E. Smith
 
Immigrant Citizens Survey: Key Findings by Thomas Huddleston
Immigrant Citizens Survey: Key Findings by Thomas HuddlestonImmigrant Citizens Survey: Key Findings by Thomas Huddleston
Immigrant Citizens Survey: Key Findings by Thomas HuddlestonTom Huddleston
 
5/10 Nervous system revised
5/10 Nervous system revised5/10 Nervous system revised
5/10 Nervous system revisedMadeleine Si
 
Презентация Асмо пресс. 2006 г.
Презентация Асмо пресс. 2006 г.Презентация Асмо пресс. 2006 г.
Презентация Асмо пресс. 2006 г.Souren M
 
Презентация Mobile-info
Презентация Mobile-infoПрезентация Mobile-info
Презентация Mobile-infoSouren M
 

Viewers also liked (20)

Presentasjon1om barnehage2
Presentasjon1om barnehage2Presentasjon1om barnehage2
Presentasjon1om barnehage2
 
Caja tema
Caja temaCaja tema
Caja tema
 
chiste
chistechiste
chiste
 
Step by step milad yussefabadi
Step by step milad yussefabadiStep by step milad yussefabadi
Step by step milad yussefabadi
 
Bienbenidos
BienbenidosBienbenidos
Bienbenidos
 
2 do grado
2 do grado2 do grado
2 do grado
 
How are you protecting your general anesthesia procedure patients from contam...
How are you protecting your general anesthesia procedure patients from contam...How are you protecting your general anesthesia procedure patients from contam...
How are you protecting your general anesthesia procedure patients from contam...
 
Презентация Mobile-Asmo
Презентация Mobile-AsmoПрезентация Mobile-Asmo
Презентация Mobile-Asmo
 
给初学者的Html5教程
给初学者的Html5教程给初学者的Html5教程
给初学者的Html5教程
 
The Engagement Effect Dig South
The Engagement Effect Dig SouthThe Engagement Effect Dig South
The Engagement Effect Dig South
 
Alta gracia =)..
Alta gracia =)..Alta gracia =)..
Alta gracia =)..
 
Respiration, etc
Respiration, etcRespiration, etc
Respiration, etc
 
Taller de computación básica
Taller de computación básicaTaller de computación básica
Taller de computación básica
 
Winning The Talent War
Winning The Talent WarWinning The Talent War
Winning The Talent War
 
Immigrant Citizens Survey: Key Findings by Thomas Huddleston
Immigrant Citizens Survey: Key Findings by Thomas HuddlestonImmigrant Citizens Survey: Key Findings by Thomas Huddleston
Immigrant Citizens Survey: Key Findings by Thomas Huddleston
 
13CH it 1
13CH it 113CH it 1
13CH it 1
 
5/10 Nervous system revised
5/10 Nervous system revised5/10 Nervous system revised
5/10 Nervous system revised
 
Презентация Асмо пресс. 2006 г.
Презентация Асмо пресс. 2006 г.Презентация Асмо пресс. 2006 г.
Презентация Асмо пресс. 2006 г.
 
MK: DP
MK: DPMK: DP
MK: DP
 
Презентация Mobile-info
Презентация Mobile-infoПрезентация Mobile-info
Презентация Mobile-info
 

Similar to 移动端Web app开发

HTML5 is the Future of Mobile, PhoneGap Takes You There Today
HTML5 is the Future of Mobile, PhoneGap Takes You There TodayHTML5 is the Future of Mobile, PhoneGap Takes You There Today
HTML5 is the Future of Mobile, PhoneGap Takes You There Todaydavyjones
 
phonegap with angular js for freshers
phonegap with angular js for freshers    phonegap with angular js for freshers
phonegap with angular js for freshers dssprakash
 
Introduction phonegap
Introduction phonegapIntroduction phonegap
Introduction phonegapRakesh Jha
 
Advanced programing in phonegap
Advanced programing in phonegapAdvanced programing in phonegap
Advanced programing in phonegapRakesh Jha
 
Dreamweaver CS6, jQuery, PhoneGap, mobile design
Dreamweaver CS6, jQuery, PhoneGap, mobile designDreamweaver CS6, jQuery, PhoneGap, mobile design
Dreamweaver CS6, jQuery, PhoneGap, mobile designDee Sadler
 
Developing Windows Phone 8 apps using PhoneGap
Developing Windows Phone 8 apps using PhoneGapDeveloping Windows Phone 8 apps using PhoneGap
Developing Windows Phone 8 apps using PhoneGapAmar Mesic
 
Building Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGap
Building Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGapBuilding Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGap
Building Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGapNick Landry
 
So you want to build a mobile app - HTML5 vs. Native @ the Boston Mobile Expe...
So you want to build a mobile app - HTML5 vs. Native @ the Boston Mobile Expe...So you want to build a mobile app - HTML5 vs. Native @ the Boston Mobile Expe...
So you want to build a mobile app - HTML5 vs. Native @ the Boston Mobile Expe...Yottaa
 
The challenges of building mobile HTML5 applications - FEEC Brazil 2012 - Recife
The challenges of building mobile HTML5 applications - FEEC Brazil 2012 - RecifeThe challenges of building mobile HTML5 applications - FEEC Brazil 2012 - Recife
The challenges of building mobile HTML5 applications - FEEC Brazil 2012 - RecifeCaridy Patino
 
Phonegap for Engineers
Phonegap for EngineersPhonegap for Engineers
Phonegap for EngineersBrian LeRoux
 
The Mobile Web Revealed For The Java Developer
The Mobile Web Revealed For The Java DeveloperThe Mobile Web Revealed For The Java Developer
The Mobile Web Revealed For The Java Developerbalunasj
 
"Native" Apps with APEX and PhoneGap
"Native" Apps with APEX and PhoneGap"Native" Apps with APEX and PhoneGap
"Native" Apps with APEX and PhoneGapChristian Rokitta
 
Mobile Apps with PhoneGap and jQuery Mobile
Mobile Apps with PhoneGap and jQuery MobileMobile Apps with PhoneGap and jQuery Mobile
Mobile Apps with PhoneGap and jQuery MobileTerry Ryan
 
Hybrid Mobile Development with Apache Cordova and
Hybrid Mobile Development with Apache Cordova and Hybrid Mobile Development with Apache Cordova and
Hybrid Mobile Development with Apache Cordova and Ryan Cuprak
 
Mobile Vue.js – From PWA to Native
Mobile Vue.js – From PWA to NativeMobile Vue.js – From PWA to Native
Mobile Vue.js – From PWA to NativeMartinSotirov
 
Responsive websites. Toolbox
Responsive websites. ToolboxResponsive websites. Toolbox
Responsive websites. ToolboxWojtek Zając
 
Lesson learned from 3 years with hybrid apps
Lesson learned from 3 years with hybrid appsLesson learned from 3 years with hybrid apps
Lesson learned from 3 years with hybrid appsPatrik Malmquist
 

Similar to 移动端Web app开发 (20)

HTML5 is the Future of Mobile, PhoneGap Takes You There Today
HTML5 is the Future of Mobile, PhoneGap Takes You There TodayHTML5 is the Future of Mobile, PhoneGap Takes You There Today
HTML5 is the Future of Mobile, PhoneGap Takes You There Today
 
phonegap with angular js for freshers
phonegap with angular js for freshers    phonegap with angular js for freshers
phonegap with angular js for freshers
 
Introduction phonegap
Introduction phonegapIntroduction phonegap
Introduction phonegap
 
Advanced programing in phonegap
Advanced programing in phonegapAdvanced programing in phonegap
Advanced programing in phonegap
 
Dreamweaver CS6, jQuery, PhoneGap, mobile design
Dreamweaver CS6, jQuery, PhoneGap, mobile designDreamweaver CS6, jQuery, PhoneGap, mobile design
Dreamweaver CS6, jQuery, PhoneGap, mobile design
 
Mobile native-hacks
Mobile native-hacksMobile native-hacks
Mobile native-hacks
 
Developing Windows Phone 8 apps using PhoneGap
Developing Windows Phone 8 apps using PhoneGapDeveloping Windows Phone 8 apps using PhoneGap
Developing Windows Phone 8 apps using PhoneGap
 
Mobile html5 v2
Mobile html5 v2Mobile html5 v2
Mobile html5 v2
 
Building Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGap
Building Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGapBuilding Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGap
Building Mobile Cross-Platform Apps with HTML5, jQuery Mobile & PhoneGap
 
So you want to build a mobile app - HTML5 vs. Native @ the Boston Mobile Expe...
So you want to build a mobile app - HTML5 vs. Native @ the Boston Mobile Expe...So you want to build a mobile app - HTML5 vs. Native @ the Boston Mobile Expe...
So you want to build a mobile app - HTML5 vs. Native @ the Boston Mobile Expe...
 
The challenges of building mobile HTML5 applications - FEEC Brazil 2012 - Recife
The challenges of building mobile HTML5 applications - FEEC Brazil 2012 - RecifeThe challenges of building mobile HTML5 applications - FEEC Brazil 2012 - Recife
The challenges of building mobile HTML5 applications - FEEC Brazil 2012 - Recife
 
Phonegap for Engineers
Phonegap for EngineersPhonegap for Engineers
Phonegap for Engineers
 
The Mobile Web Revealed For The Java Developer
The Mobile Web Revealed For The Java DeveloperThe Mobile Web Revealed For The Java Developer
The Mobile Web Revealed For The Java Developer
 
"Native" Apps with APEX and PhoneGap
"Native" Apps with APEX and PhoneGap"Native" Apps with APEX and PhoneGap
"Native" Apps with APEX and PhoneGap
 
Txjs
TxjsTxjs
Txjs
 
Mobile Apps with PhoneGap and jQuery Mobile
Mobile Apps with PhoneGap and jQuery MobileMobile Apps with PhoneGap and jQuery Mobile
Mobile Apps with PhoneGap and jQuery Mobile
 
Hybrid Mobile Development with Apache Cordova and
Hybrid Mobile Development with Apache Cordova and Hybrid Mobile Development with Apache Cordova and
Hybrid Mobile Development with Apache Cordova and
 
Mobile Vue.js – From PWA to Native
Mobile Vue.js – From PWA to NativeMobile Vue.js – From PWA to Native
Mobile Vue.js – From PWA to Native
 
Responsive websites. Toolbox
Responsive websites. ToolboxResponsive websites. Toolbox
Responsive websites. Toolbox
 
Lesson learned from 3 years with hybrid apps
Lesson learned from 3 years with hybrid appsLesson learned from 3 years with hybrid apps
Lesson learned from 3 years with hybrid apps
 

Recently uploaded

9892124323 | Book Call Girls in Juhu and escort services 24x7
9892124323 | Book Call Girls in Juhu and escort services 24x79892124323 | Book Call Girls in Juhu and escort services 24x7
9892124323 | Book Call Girls in Juhu and escort services 24x7Pooja Nehwal
 
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort ServiceDelhi Call girls
 
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,Pooja Nehwal
 
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost LoverPowerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost LoverPsychicRuben LoveSpells
 
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual serviceanilsa9823
 
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCRFULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCRnishacall1
 
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun serviceCALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun serviceanilsa9823
 

Recently uploaded (7)

9892124323 | Book Call Girls in Juhu and escort services 24x7
9892124323 | Book Call Girls in Juhu and escort services 24x79892124323 | Book Call Girls in Juhu and escort services 24x7
9892124323 | Book Call Girls in Juhu and escort services 24x7
 
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
 
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,
 
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost LoverPowerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
 
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
 
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCRFULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
 
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun serviceCALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
 

移动端Web app开发

  • 1. 移动端Web APP开发 CDC 设计研发中心 miyukizhang
  • 2. 自我介绍 • 张小雪 o Miyukizhang o 用户研究与体验设计部 • 重构&前端
  • 3. 目录 • Web Applications? • HTML5 • Web APP开发 • 最佳实践 • PhoneGap
  • 4. 目录 • Web Applications? • HTML5 • Web APP开发 • 最佳实践 • PhoneGap
  • 5. Web Applications 定义:Apps implemented with HTML5 and JavaScript that operate entirely inside a browser.
  • 6. Web App on iPhone
  • 7. Web App on iPhone
  • 10. Native App 定义:Apps developed exclusively for a specific mobile platform that can leverage all device capabilities.
  • 11. Web vs. Native Web Native Dev Cost Reasonable Expensive Dev Time Short Long Portability High No Performance Fast Very Fast Native Functionality No All Distribution No Yes
  • 12. Hybrid App 定义: Apps that wrap a mobile web interface inside a native container.
  • 14. Web vs. Hybrid vs. Native Web Hybrid Native Dev Cost Reasonable Reasonable Expensive Dev Time Short Short Long Portability High High No Performance Fast Fast Very Fast Native Functionality No Yes All Distribution No Yes Yes
  • 15. Web vs. Hybrid vs. Native 这个世界上,从来没有最好的技术或是编程 语言,只有最恰当的选择和与之匹配的解决 方案。
  • 16. 目录 • Web Applications? • HTML5 • Web APP开发 • 最佳实践 • PhoneGap
  • 17. What is HTML5 HTML5 ~= HTML + CSS3 + JS API 详细:http://slides.html5rocks.com/#landing-slide
  • 18. HTML5 for Mobile Browsers OS or Browser Platform Score (*/500) BlackBerry 10.1 » BlackBerry Q or Z series 485 Opera Mobile 15 » Android 428 Firefox Mobile 22 » Multiple platforms 422 Chrome 25 » All Android 4 devices 417 Opera Mobile 12.10 » Multiple platforms 406 iOS 6.0 » Apple iPhone, iPad and iPod Touch 386 iOS 5.0 » Apple iPhone, iPad and iPod Touch 258 Windows Phone 8 » Nokia Lumia 822, HTC 8X and others 320 Android 4.0 » Samsung Galaxy Nexus 297 http://html5test.com/
  • 19. HTML5 Elements for Mobile • Offline Support: Web database, LocalStorage, App Cache • Canvas • Video • GeoLocation • Advanced Forms • Workers • Camera
  • 20. 目录 • Web Applications? • HTML5 • Web APP开发 • 最佳实践 • PhoneGap
  • 21. 基本概念#1 • CSS pixels与device pixels o CSS pixels: 浏览器使用的抽象单位。 o device pixels: 显示屏幕的最小物理单位,每个dp包 含自己的颜色、亮度。 • 1 CSS pixels = (푑푒푣푖푐푒푃푖푥푒푙푅푎푡푖표)↑2  ∗ device pixels
  • 22. 基本概念#2 • PPI/DPI:每英寸所拥有的像素数目 屏幕分辨率(pixel): X*Y 屏幕尺寸(inch): Screen Size,即手机屏幕对角线的长度 푃푃퐼= √ 푋⁠↑2 + 푌↑2  /푆푐푟푒푒푛 푆푖푧푒 
  • 23. 基本概念#2 • PPI/DPI:每英寸所拥有的像素数目 푃푃퐼(푖푃ℎ표푛푒 4)= √ ⁠960↑2 + 640↑2  /3.5  = 330 푃푃퐼(푖푃ℎ표푛푒 5)= √ ⁠1136↑2 + 640↑2  /4  = 326
  • 24. 基本概念#3 • 密度决定比例 ldpi mdpi hdpi xhdpi 密度分界 120 160 240 320 常见屏幕尺寸 240*320 320*480 480*800 640*960 默认缩放比例 0.75 1.0 1.5 2.0
  • 25. 基本概念#3 • 密度决定比例 xxhdpi 6% Android Density xhdpi 25% hdpi 35% mdpi 23% tvdpi 1% ldpi 10% 数据来源:Android Screen Sizes and Densities
  • 26. Web APP开发#1 • Small Screen CSS o media queries <link media=“only screen and (max-device-width: 480px)” href=“mobile.css” type=“text/css” rel=“stylesheet”/> <link media=“screen and (min-device-width: 481px)” href=“standard.css” type=“text/css” rel=“stylesheet”/>
  • 27. Web APP开发#1 • Small Screen CSS o media query @media only screen and (max-device –width: 480px){ #test{ color: red; } }
  • 28. Web APP开发#2 • UserAgent 1. Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebkit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A93 Safari/419.3 2. Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebkit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543 Safari/419.3 3. Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebkit/ 531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10 Javascript: If((navigator.userAgent.match(/iPhone/i))){}
  • 29. Web APP开发#2 var pixelRatio = window.devicePixelRatio || 1; var iPhone = /iPhone/i.test(navigator.userAgent); var iPhone4 = (iPhone && pixelRatio == 2); var iPhone5 = /iPhone OS 5_0/i.test(navigator.userAgent); var iPad = /iPad/i.test(navigator.userAgent); var android = /android/i.test(navigator.userAgent); var webos = /hpwos/i.test(navigator.userAgent); var iOS = iPhone || iPad; var mobile = iOS || android || webos;
  • 30. Web APP开发#3 • iPhone Browser & Viewport meta Status Bar: 20px URL Bar: 60px Viewport: 320*356px Button Bar: 44px iPhone (非retina): 320*480px
  • 31. Web APP开发#3 • Viewport Meta <meta name=“viewport” content=”width=device-width” />
  • 32. Web APP开发#3 • Viewport Meta <meta name=”viewport” content=”width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;”/> • Initial-scale=1.0: 强制让文档的宽度与设备的宽度保持1:1 • Maximum-scale=1.0: 文档最大宽度比例是1:1 • User-scalable=0: 不允许用户点击屏幕放大浏览
  • 33. Web APP开发#4 • Safari UI(URL Bar, Status Bar) <meta name=”apple-mobile-web-app-capable” content=“yes” /> <meta name=”apple-mobile-web-app-status-bar-style” content=“black” /> • JS滚动 window.addEventListener(‘load’, function(){ setTimeout(function(){ window.scrollTo(0, 1); }, 100); })
  • 34. Web APP开发#4 • Safari UI(URL Bar, Button Bar)
  • 35. Web APP开发#5 • 主屏icon <link rel="apple-touch-icon" href=“apple-icon-iphone-57x57.png" /> <link rel="apple-touch-icon“ sizes=“72*72” href=“apple-touch-icon-72x72.png" /> <link rel="apple-touch-icon“ sizes=“114*114” href=“apple-touch-icon-114x114.png" /> <link rel="apple-touch-icon“ sizes=“144*144” href=“apple-touch-icon-144x144.png" /> 如果图标带有 -precomposed 后缀 (如: apple-touch-icon-precomposed.png) • iPhone和iPod: o 57*57px o 114*114px(retina) • iPad: o 72*72px o 144*144px(retina) composed
  • 37. Web APP开发#6 • 闪屏 <!– iPhone --> <link rel="apple-touch-startup-image“ media=“(device-width:320px) and (device-height:480px) and (-webkit-device-pixel-ratio:1)” href=“apple-touch-startup-image-320x460.png" /> <!– iPhone4/iPhone4S--> <link rel="apple-touch-startup-image“ media=“(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio:2)” href=“apple-touch-startup-image-640x920.png" /> <!– iPhone5 --> <link rel="apple-touch-startup-image“ media=“(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio:2)” href=“apple-touch-startup-image-640x1096.png" />
  • 38. Web APP开发#7 • iOS中禁止用户保存图片\复制图片 *{ -webkit-touch-callout: none; } • iOS中禁止用户选中文字 *{ -webkit-user-select: none; } .text{ -webkit-user-select: text; } • iOS横竖屏字体变化 *{ -webkit-text-size-adjust: none; }
  • 39. Web APP开发#8 • Orientation
  • 40. Web APP开发#8 • Orientation function checkOrientation(){ switch(window.orientation){ case 0: alert(‘Orientation: Portrait’); break; case 90: case -90: alert(‘Orientation: Landscape’); break; } } addEventListener(‘orientationchange’, checkOrientation);
  • 41. Web APP开发#9 • Orientation Style <body class="portrait"> window.addEventListener('load', setOrientation, false); window.addEventListener('orientationchange', setOrientation, false);
  • 42. Web APP开发#9 • Orientation Style function setOrientation() { var orient = Math.abs(window.orientation) === 90 ? 'landscape' : 'portrait'; var cl = document.body.className; cl = cl.replace(/portrait|landscape/, orient); document.body.className = cl; }
  • 43. Web APP开发#10 • Touch事件 o touchstart o touchend o touchmove o touchcancel • event对象 o touches ( 包括pageX和pageY等 ) o targetTouches • Demo
  • 44. Web APP开发#11 • 手势( gesture事件 ) o gesturestart o gestureend o gesturechange • event对象 o event.scale o event.rotate
  • 45. Web APP开发#12 • 特殊链接 <a href="tel:12345678900">Call me</a> • 避免 <meta content=”telephone=no” name=”format-detection” />
  • 46. Web APP开发#13 • Retina: background images .repeatingPattern { background: url(../images/bgPattern.png) repeat; background-size: 100px 100px; } @media only screen and (-webkit-min-device-pixel-ratio: 2) { .repeatingPattern { background: url(../images/bgPattern@2x.png) repeat; } }
  • 47. Web APP开发#13 • Retina: inline images o JS for image replacement if (window.devicePixelRatio === 2) { //Replace your img src with the new retina image }
  • 48. Web APP开发#13 • Retina: retina.js o Easy Javascript way
  • 49. Web APP开发#14 • CSS动画 o CSS Transitions o CSS 2D Transformations o CSS 3D Transformations o CSS Animations • 效果案例 兼容性: http://caniuse.com/
  • 50. Web APP开发#14 • CSS 3D Transformations(开启GPU加速) • -webkit-transform: o translate3d(tx,ty,tz); o scale3d(sx,sy,sz); o rotate3d(rx,ry,rz,angle); • Demo
  • 51. Web APP开发#15 • 调试 o Chrome调试工具 o weinre: Web Inspector Remote, 远程实时调试
  • 54. 目录 • Web Applications? • HTML5 • Web APP开发 • 最佳实践 • PhoneGap
  • 55. 体验#1 • 不要刻意模仿 iOS 的默认样式和交互 • 不要做得像个网站 • 块级化a标签 o 42*42px • 不要自己实现滚动条 o -webkit-overflow-scrolling: touch
  • 56. 体验#2 • 模拟click事件 o 300ms延时 o FastClick
  • 57. 性能#1 • 缩短class和id的命名 o hd, bd, ft; • 慎用DataURI: 多消耗53%左右的CPU资源,内 存多出4倍左右,耗时平均高出24.6倍 o base64编码增加文件大小 o 解析消耗内存和CPU o 无论是否缓存,重新解码
  • 58. 性能#2 • Zepto.js代替 jQuery.js • 尽可能少的使用box-shadows与gradients o 扁平化设计 • 使用3D CSS动画,即使你只需要2D的效果。 • 避免使用opacity • 使用AppCache
  • 59. 目录 • Web Applications? • HTML5 • Web APP开发 • 最佳实践 • PhoneGap
  • 60. What is PhoneGap PhoneGap is a free and open source framework that allows you to create mobile apps using standardized web APIs for the platforms you care about. http://phonegap.com/
  • 62. PhoneGap特征 • 开源、免费 • 跨平台框架,支持大多主流平台 • 基于HTML5标准,支持HTML5、CSS3和JS • 只写一次,到处执行 • 支持云端编译 • 包含丰富的API
  • 63. PhoneGap APIS Accelerometer Tap into the device’s motion sensor Camera Capture a photo using the device’s camera Compass Obtain the direction that the device is pointing Contacts Work with the devices contact database Device Gather device specific information Event Hook into native events through JavaScript File Hook into native file system through JavaScript Geolocation Make your application location aware Media Record and play back auto files Network Quickly check the network state Notification Visual, audible, and tactile device notification Storage Hook into the device’s native storage options
  • 64. How it work 1.用HTML5技术写一个web App HTML5/CSS/JS
  • 65. How it work 2.用PhoneGap打包你的Web App
  • 66. How it work 2.用PhoneGap打包你的Web App
  • 67. How it work 3.将你的Hybrid App 部署到各个平台 (iOS, Android等)