SlideShare a Scribd company logo
1 of 13
coServ & RWD
打造跨平台的橋樑
 在不同解析度下改變網頁頁面的佈局
 在各種裝置下以最佳的視覺體驗瀏覽網頁
響應式網頁設計(RWD)
WebSite Layout
Slider
Main
Header
Footer
Nav
Tablet Layout
Slider Main
Header
Tablet Layout
Slider Main
Header
Nav
Mobile Layout
Header
Main1
Tab Tab Tab
Header
Main2
Tab Tab Tab
Mobile Layout
Header
Main1
Tab Tab Tab
Header
Main1
Tab Tab Tab
Nav
@media only screen and (max-width: 768px) {
/*螢幕寬度768載入*/
}
@media only screen and (max-width: 600px) {
/*螢幕寬度600載入*/
}
@media only screen and (max-width: 480px) {
/*螢幕寬度480載入*/
}
傳統作法
 在www/sites.json中設定樣板
 在 JavaScript裡動態載入指定的CSS
coServ 作法
新增專案 > node cli/addSite testRWD
更改sites.json檔案結構 >
{
"127.0.0.1" : {
"theme" : {
"desktop":"desktop_theme",
"tablet" :" tablet_theme",
"mobile" :" mobile_theme"
}
}
sites.json 設定樣板
 在coServ中每個網頁都有區塊變數(bi)
 client: 判斷子端屬於何種裝置。
 用JavaScript去抓取bi.client.category來判斷裝置
 bi.client.category 參數:
'desktop' 表示是桌機,
'tablet' 表示是平板電腦,
'mobile' 則表示是手機。
在 JavaScript裡動態載入指定的CSS
在js裡判定
ctrl.startup = function () {
var bi = '<%=JSON.stringify(bi)%>';
var bi_json = JSON.parse(bi);
if (bi_json .client.category == 'mobile') {
// mobile class
}
else if (bi_json .client.category == tablet') {
//tablet class
}
else {
// website class
}
}
直接在html裡面判定
<% if (bi.client.category === 'mobile') { %>
<h2 class="mobile">This is mobile</h2>
<% } else if (bi.client.category === 'tablet') { %>
<h2 class=“tablet">This is tablet</h2>
<% } else { %>
<h2 class="desktop">This is desktop</h2>
<% } %>

More Related Content

What's hot

Responsive Web Design 響應式網頁設計
Responsive Web Design 響應式網頁設計Responsive Web Design 響應式網頁設計
Responsive Web Design 響應式網頁設計Bill Lin
 
Web Design 設計過程與合作經驗分享
Web Design 設計過程與合作經驗分享Web Design 設計過程與合作經驗分享
Web Design 設計過程與合作經驗分享Abby Chiu
 
Mobile web開發架構與入門
Mobile web開發架構與入門Mobile web開發架構與入門
Mobile web開發架構與入門Chi-wen Sun
 
20141212 html5 及微軟跨平台佈局 long
20141212 html5 及微軟跨平台佈局   long20141212 html5 及微軟跨平台佈局   long
20141212 html5 及微軟跨平台佈局 longMeng-Ru (Raymond) Tsai
 
個人網站建置介紹
個人網站建置介紹個人網站建置介紹
個人網站建置介紹Molly Lin
 
《淘宝客户端 for Android》项目实战
《淘宝客户端 for Android》项目实战《淘宝客户端 for Android》项目实战
《淘宝客户端 for Android》项目实战完颜 小卓
 
一步一步开发Html5 mobile apps
一步一步开发Html5 mobile apps一步一步开发Html5 mobile apps
一步一步开发Html5 mobile appsAdam Lu
 
Html5移动网站开发实践
Html5移动网站开发实践Html5移动网站开发实践
Html5移动网站开发实践Web Zhao
 

What's hot (10)

Responsive Web Design 響應式網頁設計
Responsive Web Design 響應式網頁設計Responsive Web Design 響應式網頁設計
Responsive Web Design 響應式網頁設計
 
Semantic ui教學
Semantic ui教學Semantic ui教學
Semantic ui教學
 
Rwd intro
Rwd introRwd intro
Rwd intro
 
Web Design 設計過程與合作經驗分享
Web Design 設計過程與合作經驗分享Web Design 設計過程與合作經驗分享
Web Design 設計過程與合作經驗分享
 
Mobile web開發架構與入門
Mobile web開發架構與入門Mobile web開發架構與入門
Mobile web開發架構與入門
 
20141212 html5 及微軟跨平台佈局 long
20141212 html5 及微軟跨平台佈局   long20141212 html5 及微軟跨平台佈局   long
20141212 html5 及微軟跨平台佈局 long
 
個人網站建置介紹
個人網站建置介紹個人網站建置介紹
個人網站建置介紹
 
《淘宝客户端 for Android》项目实战
《淘宝客户端 for Android》项目实战《淘宝客户端 for Android》项目实战
《淘宝客户端 for Android》项目实战
 
一步一步开发Html5 mobile apps
一步一步开发Html5 mobile apps一步一步开发Html5 mobile apps
一步一步开发Html5 mobile apps
 
Html5移动网站开发实践
Html5移动网站开发实践Html5移动网站开发实践
Html5移动网站开发实践
 

Similar to coServ & RWD

Responsive Web UI Design
Responsive Web UI DesignResponsive Web UI Design
Responsive Web UI Designjay li
 
Response Web Design
Response Web DesignResponse Web Design
Response Web DesignSichu Zhang
 
一淘新首页总结
一淘新首页总结一淘新首页总结
一淘新首页总结jieorlin
 
淘宝移动端Web开发最佳实践
淘宝移动端Web开发最佳实践淘宝移动端Web开发最佳实践
淘宝移动端Web开发最佳实践Du Yamin
 
淘宝移动端Web开发最佳实践
淘宝移动端Web开发最佳实践淘宝移动端Web开发最佳实践
淘宝移动端Web开发最佳实践jay li
 
Dive into Responsive Web Design
Dive into Responsive Web DesignDive into Responsive Web Design
Dive into Responsive Web Designcncuckoo
 
不一樣的Web server... coServ
不一樣的Web server... coServ不一樣的Web server... coServ
不一樣的Web server... coServBen Lue
 
Qq.com前端架构实践与思考
Qq.com前端架构实践与思考Qq.com前端架构实践与思考
Qq.com前端架构实践与思考greengnn
 
Html5和css3入门
Html5和css3入门Html5和css3入门
Html5和css3入门Xiujun Ma
 
Android 4-app
Android 4-appAndroid 4-app
Android 4-applydiafly
 
Huangjing renren
Huangjing renrenHuangjing renren
Huangjing renrend0nn9n
 
Modern Web with CSS and CSS Grid (image with links inside)
Modern Web with CSS and CSS Grid (image with links inside)Modern Web with CSS and CSS Grid (image with links inside)
Modern Web with CSS and CSS Grid (image with links inside)百範 陳
 
赶集团购开发总结4
赶集团购开发总结4赶集团购开发总结4
赶集团购开发总结4yangdj
 
浅析浏览器解析和渲染
浅析浏览器解析和渲染浅析浏览器解析和渲染
浅析浏览器解析和渲染Ailsa126
 
【项目分享】赶集移动Web App开发总结
【项目分享】赶集移动Web App开发总结 【项目分享】赶集移动Web App开发总结
【项目分享】赶集移动Web App开发总结 yangdj
 
Exam 98-375 HTML5 Application Development Fundamentals
Exam 98-375 HTML5 Application Development FundamentalsExam 98-375 HTML5 Application Development Fundamentals
Exam 98-375 HTML5 Application Development FundamentalsChieh Lin
 
使用 C#/Razor 開發互動式 WebAssembly 網站 (Modern Web 2018)
使用 C#/Razor 開發互動式 WebAssembly 網站 (Modern Web 2018)使用 C#/Razor 開發互動式 WebAssembly 網站 (Modern Web 2018)
使用 C#/Razor 開發互動式 WebAssembly 網站 (Modern Web 2018)Will Huang
 
Axis1.4 开发指南 V1.0
Axis1.4 开发指南 V1.0Axis1.4 开发指南 V1.0
Axis1.4 开发指南 V1.0yiditushe
 

Similar to coServ & RWD (20)

Responsive Web UI Design
Responsive Web UI DesignResponsive Web UI Design
Responsive Web UI Design
 
Response Web Design
Response Web DesignResponse Web Design
Response Web Design
 
一淘新首页总结
一淘新首页总结一淘新首页总结
一淘新首页总结
 
淘宝移动端Web开发最佳实践
淘宝移动端Web开发最佳实践淘宝移动端Web开发最佳实践
淘宝移动端Web开发最佳实践
 
淘宝移动端Web开发最佳实践
淘宝移动端Web开发最佳实践淘宝移动端Web开发最佳实践
淘宝移动端Web开发最佳实践
 
Dive into Responsive Web Design
Dive into Responsive Web DesignDive into Responsive Web Design
Dive into Responsive Web Design
 
不一樣的Web server... coServ
不一樣的Web server... coServ不一樣的Web server... coServ
不一樣的Web server... coServ
 
Qq.com前端架构实践与思考
Qq.com前端架构实践与思考Qq.com前端架构实践与思考
Qq.com前端架构实践与思考
 
Html5和css3入门
Html5和css3入门Html5和css3入门
Html5和css3入门
 
Android 4-app
Android 4-appAndroid 4-app
Android 4-app
 
Huangjing renren
Huangjing renrenHuangjing renren
Huangjing renren
 
Modern Web with CSS and CSS Grid (image with links inside)
Modern Web with CSS and CSS Grid (image with links inside)Modern Web with CSS and CSS Grid (image with links inside)
Modern Web with CSS and CSS Grid (image with links inside)
 
赶集团购开发总结4
赶集团购开发总结4赶集团购开发总结4
赶集团购开发总结4
 
Wap2.0
Wap2.0Wap2.0
Wap2.0
 
Wap2.0
Wap2.0Wap2.0
Wap2.0
 
浅析浏览器解析和渲染
浅析浏览器解析和渲染浅析浏览器解析和渲染
浅析浏览器解析和渲染
 
【项目分享】赶集移动Web App开发总结
【项目分享】赶集移动Web App开发总结 【项目分享】赶集移动Web App开发总结
【项目分享】赶集移动Web App开发总结
 
Exam 98-375 HTML5 Application Development Fundamentals
Exam 98-375 HTML5 Application Development FundamentalsExam 98-375 HTML5 Application Development Fundamentals
Exam 98-375 HTML5 Application Development Fundamentals
 
使用 C#/Razor 開發互動式 WebAssembly 網站 (Modern Web 2018)
使用 C#/Razor 開發互動式 WebAssembly 網站 (Modern Web 2018)使用 C#/Razor 開發互動式 WebAssembly 網站 (Modern Web 2018)
使用 C#/Razor 開發互動式 WebAssembly 網站 (Modern Web 2018)
 
Axis1.4 开发指南 V1.0
Axis1.4 开发指南 V1.0Axis1.4 开发指南 V1.0
Axis1.4 开发指南 V1.0
 

coServ & RWD