Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
NTU CCSP 2012Fall - Mobile Web入門 回首網頁開發
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Steven Su
December 12, 2012
Programming
320
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
NTU CCSP 2012Fall - Mobile Web入門 回首網頁開發
Steven Su
December 12, 2012
More Decks by Steven Su
See All by Steven Su
JSDC.TW 2013 Node.js佈署心得
xpsteven
14
1.2k
NTU CCSP 2012Fall - Facebook
xpsteven
1
220
NTU CCSP 2012Fall - Node.js #2.1 - Simple File Host Service
xpsteven
2
460
NTU CCSP 2012Fall - Node.js #3 - Mongoose
xpsteven
2
740
NTU CCSP 2012Fall - Node.js #2 - express.js
xpsteven
3
580
Y! Open Hack 2012 Taiwan
xpsteven
0
200
NTU CCSP 2012Fall - Node.js #2 - Advanced Javascript and Node.js
xpsteven
1
560
Other Decks in Programming
See All in Programming
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
6.2k
AIで効率化できた業務・日常
ochtum
0
140
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
130
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
5.1k
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
180
肥大化するレガシーコードに立ち向かうためのインターフェース分離と依存の逆転 / JJUG CCC 2026 Spring
hirokunimaeta
0
560
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
540
New "Type" system on PicoRuby
pocke
1
940
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
510
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
11
4.2k
Javaの型とAI時代に型が大事な理由 / java types and type in AI era
kishida
2
140
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
610
Build your cross-platform service in a week with App Engine
jlugia
234
18k
4 Signs Your Business is Dying
shpigford
187
22k
Utilizing Notion as your number one productivity tool
mfonobong
4
320
The agentic SEO stack - context over prompts
schlessera
0
820
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
540
Between Models and Reality
mayunak
4
340
Designing Experiences People Love
moore
143
24k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
Thoughts on Productivity
jonyablonski
76
5.2k
Color Theory Basics | Prateek | Gurzu
gurzu
0
360
Transcript
Mobile Web入門 回首網頁開發 NTU CCSP 2012Fall
• mobile device普及的時候,針對 mobile最佳化的網頁還不多,所以有 viewport的設計。 • viewport:rendering engine認為的畫 面大小。 •
在desktop,viewport大小同browser 大小。 • 為了讓mobile device可以瀏覽一般 網頁,另為導入scale機制。 #1 a pixel is not a pixel
mobile最佳化 • <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1.0, minimum-scale=1.0"> •
把上面這行加到head裡 • width=device-width ◦ viewport寬度同裝置寬度 • initial-scale=1.0, user-scalable=no, maximum-scale=1.0, minimum- scale=1.0 ◦ 完全鎖死放大與縮小 ◦ 缺一不可 • viewport metadata在desktop是無用的
#2 scrollbar • 再見,難看的scrollbar。 • http://css-tricks.com/custom-scrollbars-in-webkit/ • webkit only QQ
::-webkit-scrollbar { width: 12px; } ::-webkit-scrollbar-track { -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); border-radius: 10px; } ::-webkit-scrollbar-thumb { border-radius: 10px; -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5); } ::-webkit-scrollbar-thumb { background: #999; }
#3 更多 • 捲動阻尼與動能 ◦ * {-webkit-overflow-scrolling: touch;} • 移除按鈕顏色
◦ * {-webkit-tap-highlight-color:rgba(0,0,0,0);} •
what is webkit • Safari的核心 所以是蘋果公司的 但開放原始碼 ◦ 其實apple對open source也是有貢獻的
◦ 包含著名的LLVM專案 • 網頁排版/渲染引擎+JS引擎 ◦ 動態網頁技術讓兩者越來越密不可分 • 源自開源桌面系統KDE • Chrome也是webkit-based但改用買來的V8 engine
#4 js scroller • native scroller ◦ 不需要js ◦ 比較侷限
• js scoller ◦ 用大廠牌的就對了 ◦ https://github.com/zynga/scroller ◦ Demo ▪ http://zynga.github.com/scroller/demo/easyscroller.html ▪ http://zynga.github.com/scroller/demo/dom-snapping.html
#5 touchstart • click和touch傻傻分不清楚 • webkit-based導入300ms的點擊延遲 • 只對按鈕使用touchstart事件 • $('body').on('touchstart
click', 'a', function(e){...}); • 或使用套件 https://github.com/ftlabs/fastclick
#6 position: fixed • mobile web在去年對position: fixed的支援度還不高 • 目前算是相對健全了 http://caniuse.com/
#7 transform/transition很吃資源 • http://csc-studio.tumblr.com/post/25840306358 • 啟用3D加速 • 原則:不要為了特效而特效 • 比起沒有特效
使用者更討厭讀取慢和crash *{ -webkit-backface-visibility: hidden; -webkit-perspective: 0; -webkit-transform-style: preserve-3d; -webkit-transform: translate3d(0,0,0) rotate(0) scale(1); }
#8 APP包WEB? • 俗稱WebView-Based App • 框架 ◦ PhoneGap ◦
Sencha Touch ◦ jQuery mobile • 優點 ◦ 讓Web開發人員可以開發App • 缺點 ◦ write once debug everywhere ◦ webview和mobile web browser的效能有差
#9 即使是chrome... • 雖然chrome的開發者工具可以調整user-agent和視窗大小 • 但沒有真的在mobile browser上跑過 是不能知道bug的.... • 例如
◦ 位置transition有機率破壞touchstart事件的觸發 ◦ fixed+transition也會破壞touchstart事件的觸發 ◦ 可能是瀏覽器內和在動畫結束後沒有重新計算事件觸發的區域
#10 不只要會用套件 • 更要能改套件與看懂套件的code • 例如bootstrap的dropdown不能正確收闔的bug ◦ https://github.com/twitter/bootstrap/issues/5094
#11 media query /* Large desktop */ @media (min-width: 1200px)
{ ... } /* Portrait tablet to landscape and desktop */ @media (min-width: 768px) and (max-width: 979px) { ... } /* Landscape phone to portrait tablet */ @media (max-width: 767px) { ... } /* Landscape phones and down */ @media (max-width: 480px) { ... } • 幾個重要的值 ◦ 1024px landscape ipad ◦ 768px portrait ipad ◦ 480px landscape iphone ◦ 320px portrait iphone
#12 media query的小問題 • 前面有提到桌面瀏覽器不能鎖死viewport • Ctrl+與Ctrl-會調整CSS pixel • 最好的CSS單位其實是em
但很難用.... • 結法 ◦ 盡量避免overflow: hidden
#13 Responsive Web Design • RWD ◦ 相對減少人力需求 ◦ 較難最佳化
▪ 最佳化過頭不就變成SD • Specific Design ◦ 最佳化顯示 ◦ 需要較多人月 ◦ stackoverflow.com
#14 Real-Time Web var io = require('socket.io').listen(80); io.sockets.on('connection', function (socket)
{ socket.emit('news', { hello: 'world' }); socket.on('my other event', function (data) { console.log(data); }); }); /////////////////////////////////////////////////////////////////////////////////////////////////////////// <script src="/socket.io/socket.io.js"></script> <script> var socket = io.connect('http://localhost'); socket.on('news', function (data) { console.log(data); socket.emit('my other event', { my: 'data' }); }); </script>
#15 WebGL • https://turbulenz.com/ • three.js https://github.com/mrdoob/three.js/ • desktop browser除了IE都ready了
◦ MS覺得安全性有問題?! • mobile borwser都還沒 哭哭 • 有可能大幅改變遊戲生態系
#16 Audio • Audio tag ◦ iOS需要使用者觸發 • Audio API
◦ 不建議使用
#17 WebRTC • http://updates.html5rocks.com/2012/12/WebRTC-hits-Firefox-Android-and- iOS • Android/iOS/Chrome/Firefox Ready • http://www.webrtc.org
• Google主推 • UDP-based => 較好的防火牆穿透 • 應用 ◦ P2P ◦ 即時視訊
#18 Stream API • http://www.html5rocks.com/en/tutorials/getusermedia/intro/
QA時間