国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Html5+css3+angularjs+jquery+webAPi 開發手機web(一)

2019-11-17 02:09:42
字體:
來源:轉載
供稿:網友

Html5+CSS3+angularjs+jquery+webAPi 開發手機web(一)

前言

隨著瀏覽器的發展 HTML5+CSS3 的使用也越來越廣泛,一直想學這個,想學那個折騰下來幾乎沒學到什么東西。工作經驗告訴我,要掌握一門技術,就需要在項目中去磨練,

所以我就準備開發一個手機端的BBS練練手,技術更新快,也要學的快,跟的上時代,才漲的了工資。

技術的選擇

jQuery Mobile Phone Gap 等都是比較成熟的框架為什么我不用這些框架呢? 因為我考慮到底層的技術應用和練習 。

我的選擇是:Html5+css3+angularjs+jquery

HTML5+CSS3 負責UI布局

angularjs 負責數據請求與綁定

jquery 負責頁面動畫效果

webApi 負責服務端數據接口

首頁布局

如圖:

步驟一、設置網頁的大小為移動設置的大小

在head添加meta標簽name為viewport,content參數請看圖中的解釋:

步驟二、編寫HTML

頁面總共分為頭部、主體、和底部三大塊。 HTML結構如下:

步驟三、樣式的編寫

(1)、字體設置為瀏覽器默認大小

html{font-size: 100%;}//字體為瀏覽器默認大小 body{font-size: 1.0em;} //1em等于默認字體大小(比如瀏覽器默認字體大小為16px,1em就等于16px)

(2)、編寫頭部樣式

1、為了適應所有瀏覽器,單位都采用em或者百分比

2、頭部左邊的可愛圖片和右邊的發貼按鈕,使用float:left和float:right 左右定位,為了讓和中間的標題文字在一條直線上使用了 position:relative 加 top進行定位(圖片和文字一般都不在一條直線上)

header h3{background: url(/img/common/line1.png) ; background-repeat:repeat-x;height: 3em;line-height: 3em;margin: 0;padding: 0;color: white;width: 100%; text-align:center}header h3 img{ position:relative; top:0.8em; float:left; margin-left:0.5em}header h3 .action-write-msg { outline:none; position:relative; top:0.8em;float: right;text-align: center; height: 2.5em;color: #fff; line-height: 0.5em;font-size: .875rem;border: 1px solid #e86b0f;border-radius: 4px; padding: 0 1.5em;background-color: #ff8200; margin-right:0.5em}header h3 .action-write-msg:hover{background-color: #e86b0f}

(3)、編寫主體部分樣式

主體部體非常重要,需要保證中間可以滾動并且底部一直在最下面

使用:

position: fixed;top:4em 使主體部分一直浮動在瀏覽器頂部向下4em位置, 可以保證懸浮了,但是高度還是有問題

height:calc(100% - 8em); 我們知道頭部是4em 底部也是4em 那主體部分高度就是 100%-8em

overflow-y:scroll 上下滾動

article{position: fixed; overflow-y:scroll; top:4em; width: 100%; height:calc(100% - 8em);  }article>ul{text-align:center;}article>ul li{  display:inline-block; background:#fff; width:40%;height:8em; border-radius:10%; margin:0.5em;line-height:2em; border:solid #fff 0.2em }article>ul li:hover{ border:0.2em  dashed red}article>ul li img{margin-top:1em}article>ul li .title{ font-weight:bold;}

(4)、編寫底部樣式
footer a {color: #B4E0D0;text-decoration: underline;margin: 5px;}footer a.current{ text-decoration:none; color:#fff}footer { font-size:0.7em;background: url(/img/common/line1.png);position: absolute;height: 3.5em;line-height: 1.5em;margin: 0;padding-top:0.5em ;color: white;width: 100%;text-align: center;bottom: 0em;clear: both; background-repeat:repeat-x;}

  

步驟四、angular綁定數據

(1)、聲名一個module
var layoutApp = angular.module('layoutApp', []);
(2)、編寫module下的controller
layoutApp.controller('headController', function ($scope) {     $scope.title = "
(3)、html綁定

demo地址:

https://github.com/sunkaixuan/AutoLayout

。。待續


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 沧州市| 龙海市| 招远市| 秦皇岛市| 蕉岭县| 桑植县| 武城县| 喀喇沁旗| 定州市| 海盐县| 泗阳县| 莱西市| 莱州市| 蓝山县| 浦北县| 衡阳县| 连城县| 盘山县| 莎车县| 通海县| 潼关县| 德兴市| 东乡| 孝义市| 都江堰市| 安远县| 香格里拉县| 靖宇县| 廉江市| 虎林市| 茶陵县| 福州市| 大兴区| 巴青县| 百色市| 曲沃县| 盐津县| 榆中县| 泌阳县| 黔江区| 称多县|