(Hyper Text Markup Language) 超文本標記語言,用於描述網頁的一種語言。
2,HTML5相關知識?
HTML
XHTML
Css
Css3
JavaScript
JQuery
HTML5
3,HTML5新特性?
1,繪畫:canvas標籤
2,媒介:video和audio元素
3,存儲:本地離線存儲
4,新元素:article,footer,header,nav,section
5,新控件:calendar,date,time,email,url,search
6,瀏覽器:Safari,Chrome,Firefox,Opera,IE9
HTML基礎講解
4,聲明:<!DOCTYPE>
5,HTML基礎標籤:head,body
6,HTML標題
<h1>...<h6>等標籤進行定義
7,HTML段落
<p>標籤定義段落
8,HTML連接
<a>標籤定義連接
9,HTML圖像
<img>標籤定義圖像
10,HTML元素
是從開始標籤到結束標籤的所有代碼。即元素的內容
空元素在開始標籤進行閉合。如:<br/>
大多數的元素有屬性,都可以嵌套的。如:<p> <a>hello </a></p>
11,HTML屬性
標籤可以擁有屬性爲元素提供更多是信息。
屬性是以鍵值對的形式。如:href="www.baidu.com"
常用標籤屬性:<h1> align:對齊方式;<body> bgcolor:背景顏色;<a> target:規定在何處打開鏈接;
通用屬性:class:規定元素的類名;id:規定元素的唯一ID; style:規定元素的樣式; title:規定元素的額外信息;
12,HTML格式化
<b> 粗體文本
<big> 大號字
<em> 着重文字
<i> 斜體字
<small> 小號字
<strong> 加重語氣
<sub> 下標字
<sup> 上標字
<ins> 插入字
<del> 刪除字
13,HTML樣式
標籤:<style> 樣式定義 ; <link> 資源引用
屬性:rel="stylesheet" 外部樣式表; type="text/css" 引入文檔類型; margin-left 邊距;
插入方法:外部樣式表 <link rel="stylesheet" type="text/css" href="mystyle.css">
內部樣式表 <style type="text/css">
body { background-color :red}
p { margin-left:20px }
</style>
內聯樣式表 <p style= "color:red">
14,HTML鏈接
數據:文本鏈接;圖片鏈接;
屬性:href屬性 指向另一個文檔的鏈接; name屬性 創建文檔內的鏈接;
img標籤屬性;alt 替換文本屬性; width 寬 ; height 高;
15,HTML表格
<table> 表格
<caption> 表格標題
<th> 表頭
<tr> 行
<td> 單元
<thead> 頁眉
<tbody> 主體
<tfoot> 頁腳
<col> 列屬性
16,THML列表
標籤:<ol> 有序; <ul> 無序; <li> 列表項; <dl> 列表; <dt> 列表項; <dd> 描述;
無序列表:標籤 <ul><li> 屬性 disc , circle, square;
有序列表:標籤 <ol><li> 屬性 A, a, I, i, start;
嵌套列表:標籤 <ul><ol><li>
自定義列表:標籤 <dl><dt><dd>
17,HTML塊
塊的元素:塊元素顯示時,通常以新行開始; 如:<h1><p><ul>
內聯元素:內聯元素通常不會以新行開始; 如:<b><a><img>
<div>元素:<div>元素也被稱爲塊元素,其主要的組合HTML元素的容器。
<span>元素:<span>元素是內聯元素,可作爲文本的容器。
18,HTML佈局
①div佈局
②table元素佈局
顯示結果
|
描述
|
實體名稱
|
實體編號
|
---|---|---|---|
|
空格
|
|
|
<
|
小於號
|
<
|
<< p=""><!--
|
>
|
大於號
|
>
|
>
|
&
|
和號
|
&
|
&
|
"
|
引號
|
"
|
"
|
'
|
撇號
|
' (IE不支持)
|
'
|
¢
|
分
|
¢
|
¢
|
£
|
鎊
|
£
|
£
|
¥
|
人民幣
|
¥
|
¥
|
|
|
|
|
normal | 默認值。定義標準的字符。 |
bold | 定義粗體字符。 |
bolder | 定義更粗的字符。 |
lighter | 定義更細的字符。 |
|
定義由粗到細的字符。400 等同於 normal,而 700 等同於 bold。 |
inherit | 規定應該從父元素繼承字體的粗細。 |
尺寸
單位 | 描述 |
---|---|
% | 百分比 |
in | 英寸 |
cm | 釐米 |
mm | 毫米 |
em |
1em 等於當前的字體尺寸。 2em 等於當前字體尺寸的兩倍。 例如,如果某元素以 12pt 顯示,那麼 2em 是24pt。 在 CSS 中,em 是非常有用的單位,因爲它可以自動適應用戶所使用的字體。 |
ex | 一個 ex 是一個字體的 x-height。 (x-height 通常是字體尺寸的一半。) |
pt | 磅 (1 pt 等於 1/72 英寸) |
pc | 12 點活字 (1 pc 等於 12 點) |
px | 像素 (計算機屏幕上的一個點) |
顏色
單位 | 描述 |
---|---|
(顏色名) | 顏色名稱 (比如 red) |
rgb(x,x,x) | RGB 值 (比如 rgb(255,0,0)) |
rgb(x%, x%, x%) | RGB 百分比值 (比如 rgb(100%,0%,0%)) |
#rrggbb | 十六進制數 (比如 #ff0000) |
循環體;
$("#clickMeBtn").bind("click",clickHandler);
$("#clickMeBtn").bind("click",clickHandler1);
$("#clickMeBtn").unbind("click",clickHandler1);//解除指定的綁定,方法---不帶()
/*jquery 1.7之後 on代替 bind */
$("#clickMeBtn").on("click",clickHandler);
$("#clickMeBtn").on("click",clickHandler1);
$("#clickMeBtn").off("click");//解除所有綁定。方法---不帶()
|
e.stopPropagation();//阻止父級事件冒泡,body不再打印信息
e.stopImmediatePropagation();//阻止所有事件冒泡
|
clickBtn= $("#clickBtn");
clickBtn.click(function(){
var e =jQuery.Event("MyEvent");//創建自己的事件
clickBtn.trigger(e);//觸發
});
clickBtn.bind("MyEvent",function(e){//事件要傳遞進來
conlog(e);
});
|
$("#hide").click(function (){
$("#phide").hide(1000);//點擊隱藏--動畫1s
});
$("#show").click(function (){
$("#phide").show(1000);//點擊顯示--動畫1s
});
$("#toggle").click(function (){
$("#phide").toggle(1000);//點擊顯示--動畫1s
});
|
/*淡入淡出*/
$("#in").click(function(){
$("#div1").fadeIn(1000);
$("#div2").fadeIn(1000);
$("#div3").fadeIn(1000);
});
$("#out").click(function(){
$("#div1").fadeOut(1000);
$("#div2").fadeOut(1000);
$("#div3").fadeOut(1000);
});
$("#fadetoggle").click(function(){//開關
$("#div1").fadeToggle(1000);
$("#div2").fadeToggle(1000);
$("#div3").fadeToggle(1000);
});
$("#fadeto").click(function(){//透明度
$("#div1").fadeTo(1000,0.5);
$("#div2").fadeTo(1000,0.7);
$("#div3").fadeTo(1000,0.3);
});
|
$("#flipshow").click(function(){//顯示(之前在樣式中displayed:nono)
$("#content").slideDown(500);
});
$("#fliphide").click(function(){//隱藏
$("#content").slideUp(500);
});
$("#fliptoggle").click(function(){//開關
$("#content").slideToggle(500);
});
|
/*回調*/
$("#btn").click(function(){
// $("p").hide(1000,function(){//單獨執行
// alert("動畫結束,方法回調")
// });
$("p").css("color","red").slideUp(500).slideDown(500);//多個設置和動畫
});
|
/*獲取*/
$("#btn1").click(function(){
// alert("text:"+$("#text").text());//text()獲取內容
// alert("text:"+$("#text").html());//html()獲取全部內容,包含標籤
alert("text:"+$("#input").val());//val()獲取輸入框內容
});
$("#btn2").click(function(){
alert("網址:"+$("#aid").attr("href")+",ID:"+$("#aid").attr("id"));//attr()獲取屬性
});
});
|
/*設置*/
$("#btn3").click(function(){ $("#p1").text("極客學院");//修改P標籤內容 }); $("#btn4").click(function(){ $("#p2").t("<a href='http://www.jikexueyuan.com'>極客學院2</a>");//給p標籤添加a標籤 }); $("#btn5").click(function(){ $("#i3").val("jikexueyuan");//修改input的內容 }); $("#btn6").click(function(){ // $("#a").attr("href","http://www.jikexueyuan.com");//修改input的內容 $("#a").attr({ "href":"http://www.jikexueyuan.com", "title":"hello" }); $("#a").text("極客學院"); }); $("#btn7").click(function(){ $("#p5").text(function(i,ot){//顯示不斷返回的數據,新的和舊的。 return "old:"+ot+", new:"+i; }); }); |
/*添加*/
/*說明:
* append:在元素結尾添加;
* before,prepend:在元素之前添加;
* after:在元素之後添加
* */
$("#btn8").click(function(){
// $("#p6").append("this is a web");//結尾
$("#p6").prepend("this is a web");//之前
});
$("#btn9").click(function(){
// $("#p7").before("this is a web");//在上一行
$("#p7").after("this is a web");//在下一行
});
});
function appendText(){
/*三種方式添加內容:
*html,jQuery,DOM
* */
var text1="<p>iwen</p>";
var text2=$("<p></p>").text("iwe");
var text3=document.createElement("p");
text3.innerHTML="iw";
$("body").append(text1,text2,text3);
}
|
/*刪除*/
/*方法:
* remove,empty
* */
$("#btn10").click(function(){
$("#div").remove();//全刪除
// $("#div").empty();//刪除元素內容
});
|
/*css 方法*/
var div=$("#div1");
// div.css("width","100px");//單個設置屬性
// div.css("height","100px");
// div.css("background","#FF0000");
// div.css({//設置多個屬性
// width:"100px",height:"100px",backgroundColor:"#00FF00"
// });
div.addClass("style1");//加載一個class樣式。
div.click(function(){
// $(this).addClass("style2");
// $(this).removeClass("style1");//點擊移除樣式
$(this).toggleClass("style2");//更換
});
|
/*盒子模型*/
var d= $("#div2");//獲得div高度
d.click(function(){
// alert(d.height());//寬 100
// alert(d.innerHeight());//高+邊距 200
alert(d.outerHeight());// 高+邊距+外邊框 204
alert(d.outerHeight(true));// 高+邊距+外邊框+外邊距 304
});
|
/*向下遍歷
* children, find
* */
// $("#div1").children().css({//指向下延伸一級
// border:"3px solid #FF0000"
// });
$("#div1").find("a").css({//必填元素,修改指定元素
border:"3px solid #FF0000"
});
|
/*向上遍歷
* parent, parents, parentUntil
* */
// $("p").parent().css({//父邊框一級 變
// border:"3px solid #FF0000"
// });
// $("p").parents().css({//外面的所有 變
// border:"3px solid #FF0000"
// });
$("a").parentsUntil("#div1").css({//指定元素之間區間 變
border:"3px solid #FF0000"
});
|
/*同級遍歷
* sibings,next,nextALl,nextUntil,preAll,preUntil
* */
// $("h4").siblings().css({//修改其他所有同級元素
// border:"5px solid #FF0000"});
// $("h2").next().css({//修改下一個同級元素
// border:"5px solid #FF0000"});
// $("h2").nextAll().css({//修改下一個所有同級元素
// border:"5px solid #FF0000"});
// $("p").nextUntil("h4").css({//修改在兩個之間的所有同級元素
// border:"5px solid #FF0000"});
// $("h3").prevAll().css({//修改在次之前的的所有同級元素
// border:"5px solid #FF0000"});
$("h5").prevUntil("h2").css({//修改在兩個之間倒序的的所有同級元素
border:"5px solid #FF0000"});
|
/*過濾
* first, last,eq, filter, not
* */
// $(".div p").first().css("background-color","red");//第一個
// $(".div p").last().css("background-color","red");//最後一個
// $(".div p").eq(1).css("background-color","red");//索引指定下標的元素,從零開始
// $(".div p").filter(".a").css("background-color","red");//滿足所有的集合
$(".div p").not(".a").css("background-color","red");//與filter相反的效果
|
if(isset($_GET['name'])){
echo "hello:".$_GET['name']; }else{
echo "Args Error"; } |
$("#btn").on("click",function(){ |
/*加載htm碎片,添加到div中*/ |
/*方式1*/
$.myjq=function(){
alert("Hello myjQuery");
}
/*方式2*/
$.fn.myjq=function(){
$(this).text("Hello");
}
/*jQuery擴展:引入script,兩種方式調用*/
$.myjq();//方式1:彈出對話框
$("#div").myjq();//方式2:打印內容
|
$(document).ready(function(){
$(window).on("load",function(){
imgLocation();
var dataImg={"data":[{"src":"e1.png"},{"src":"e2.png"},{"src":"e3.png"},{"src":"e4.png"},{"src":"e5.png"},{"src":"e6.png"},{"src":"e7.png"},{"src":"e8.png"},{"src":"e9.png"}]}
window.onscroll=function(){//屏幕滾動監聽
// conlog(scrollSlide())
if(scrollSlide()){
//循環json數據,創建box
$.each(dataImg.data,function(index,value){
var box=$("<div>").addClass("box").appendTo($("#container"));
var content=$("<div>").addClass("content").appendTo(box);
$("<img>").attr("src","./images/"+$(value).attr("src")).appendTo(content);
});
imgLocation();
}
}
});
});
/*滾動底部時 計算高度*/
function scrollSlide(){
var box=$(".box");
//獲取當前對象距離頂端的距離+圖片高度。
var lastboxHeight=box.last().get(0).offsetTop+Math.floor(box.last().height()/2);
var documentHeight=$(document).width();//當前屏幕的高度,注意()
var scrollHeight=$(window).scrollTop();//滾動的高度
// conlog(lastboxHeight/2+"---"+documentHeight+"---"+scrollHeight)
return (lastboxHeight<scrollHeight+documentHeight)?true:false;
}
/*佈局圖片擺放位置*/
function imgLocation(){
var box=$(".box");//獲取所有的box
var boxWidth=box.eq(0).width();//獲取第一個box的寬度
var num=Math.floor($(window).width()/boxWidth);//每一行顯示的個數
var boxArr=[];
box.each(function(index,value){//.each()相當於for循環,設置每一個box
conlog(index+"---"+value);
var boxHeight=box.eq(index).height();//每一個box的高度集合
if(index<num){//第一行的顯示圖片的高度,添加到boxArr數組中
boxArr[index]=boxHeight;//數組需要索引,[index]
// conlog(boxHeight);
}else{
var minHeight=Math.min.apply(null,boxArr);//.min.apply(null,數組):獲得最小高度
// conlog(minHeight);
var minboxIndex= $.inArray(minHeight,boxArr);//,inArray(minHeight,數組):獲得最小高度的下標
$(value).css({//$(value):獲得一個box實例,設置樣式
"position":"absolute",
"top":minHeight,
"left":box.eq(minboxIndex).position().left
});
//選出一個最小圖片底部放置後,重新計算第一行的數組中高度。
boxArr[minboxIndex]+=box.eq(index).height();
}
});
}
/*用於打印*/
function conlog(e){
console.log(e)
}
|
$("#div").draggable();//調用方法拖動
|
$("#Rect2").droppable();//放置
$("#Rect2").on("drop",function(e,ui){//拖動進元素時,觸發事件。
// alert(e);
$("#Rect2").text("drops事件");
});
|
$("#div1").resizable();//可調整邊框
|
$("#btn").button();
$("#select").selectable();
$("#btn").on("click",function(){
if($("#right").hasClass("ui-selected")){
alert("答對了!") }
});
<!-- href="#":表示不跳轉-->
<a href="#" id="btn">提交</a>
|
$("#sortable").sortable();//可拖動排序
|
$("#accordion").accordion();//可摺疊,手風琴效果
|
/*承載提示內容*/
var autoTags=["iwen","ime","html","css","javascript","java","android", "ios"];
$("#tags").autocomplete({
source:autoTags//指定其資源
});
|
$("#datepicker").datepicker();//事件選擇器
|
$("#btn_dialog").button().on("click",function(){
$("#div2").dialog();//彈出對話框
});
|
pb =$("#pb");
// pb.progressbar({value:50});
pb.progressbar({max:100});
setInterval(changePb,100);//設置定時器
/*設置改變pb進度條*/
function changePb(){
current++;
if(current>=100){
current=0;
}
pb.progressbar("option","value",current);//設置增加的數值:
}
|
$("#menu").menu({position:{at:"left bottom"}});//設置顯示位置:左下方
.ui-menu:after{
content: ".";
display: block;
/*在左右兩側均不允許浮動元素。*/
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
.ui-menu .ui-menu-item{ //條目的屬性
display: inline-block;
float: left;
margin: 0;
padding: 10;
width: auto;
}
|
var slider=$("#slider");
// slider.slider();
var valueSpan= $("#span");
slider.slider({
// change:function(e,ui){//傳遞兩個參數,拖動後顯示拖動值。
// valueSpan.text(slider.slider("option","value"));
// }
slide:function(e,ui){//拖動過程中,不斷變化着。
valueSpan.text(slider.slider("option","value"));
}
});
|
/*下拉列表*/
var sp=$("#input");
sp.spinner();
sp.spinner("value","10");
$("#btn3").click(function(){
alert(sp.spinner("value"))//獲取spinner的值
});
/*Tags標籤*/
$(function(){
$("#tag").tabs();
});
|
/*Addclass:改變的class,執行時間,動畫效果,完成監聽
*/
$(".div5").on("click",function(){
$(this).addClass("changeddiv",1000,"easeInCirc",function(){
alert("動畫完成");
});
});
$(document).click(function(){//點擊執行百葉窗的效果:方向
$("#toggle").toggle("blind",{direction:"down"});
});
|
/*Animtion 修改背景*/
$("#btn_toggle").click(function(){
$("#elem").animate({color:"green",
backgroundColor:"rgb(99,99,99)",
borderColor:"rgb(199,199,199)"});
/*向左逐漸隱藏,執行三秒*/
$("#toggle").hide("drop",{dirction:"left"},3000);
/*RemoveClass:移除class*/
$(".div5").removeClass("changeddiv",1000,"easeInCirc",function(){
alert("動畫完成");
});
});
|
/*逐漸顯示*/
$("#toggle").show("drop",2000);
$(this).toggleClass("changeddiv",2000,"easeOutSine");//將添加和移出class集中一體
|
<!--在移動設備上適配,增加字段 meta name="viewport" content="width=device-width,initial-scale=1.0"-->
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>JQuery Mobile</title>
<!--導入jQuery Mobile的js和css-->
<script src="js/jquery-2.1.3.min.js"></script>
<script src="js/jquery.mobile-1.4.5.min.js"></script>
<link href="css/jquery.mobile-1.4.5.min.css" rel="stylesheet" type="text/css">
<!--在body中是data-role="page"固定:三部分字段data-role="header",role="main",data-role="footer"-->
<!--固定頭部或底部位置:data-position="fixed"-->
<div data-role="page">
<!--頭-->
<div data-role="header" data-position="fixed">
<h1>這是頭部</h1>
</div>
<!--身-->
<div role="main">
<p>Hello</p> <p>Hello</p> <p>Hello</p> <p>Hello</p> <p>Hello</p>
</div>
<!--腳-->
<div data-role="footer" data-position="fixed">
<h1>這是腳部</h1>
</div>
</div>
|
<a href="#pagetwo" data-transition="slide">跳轉到第二個頁面</a>
<a href="#pagetwo" data-rel="dialog">打開一個dialog</a>
|
<button>按鈕</button>
<input type="button" value="按鈕">
<a href="#" class="ui-btn ui-shadow">按鈕</a>
<!--按鈕加圖片的效果:刪除圖標ui-icon-delete,不顯示文字ui-btn-icon-notext-->
<a href="#" class="ui-btn ui-icon-delete ui-btn-icon-notext ui-corner-all" >按鈕</a>
<!--一排顯示按鈕:ui-btn-inline-->
<a href="#" class="ui-btn ui-btn-inline" >按鈕1</a>
<a href="#" class="ui-btn ui-btn-inline" >按鈕2</a>
<!--一組:data-role="controlgroup",橫向相連接:data-type="horizontal"-->
<div data-role="controlgroup" data-type="horizontal">
<a href="#" class="ui-btn ui-shadow ui-btn-inline">按鈕1</a>
<a href="#" class="ui-btn ui-shadow ui-btn-inline">按鈕2</a>
<a href="#" class="ui-btn ui-shadow ui-btn-inline">按鈕3</a>
</div>
<!--主題:ui-btn-a-->
<a href="#" class="ui-btn ui-btn-a ">主題1</a>
<a href="#" class="ui-btn ui-btn-b ">主題2</a>
|
<!--複選框-->
<label>
<input type="checkbox">蘋果
</label>
<!--複選框組-->
<fieldset data-role="controlgroup" data-type="horizontal">
<label>
<input type="checkbox">蘋果
</label>
<label>
<input type="checkbox">蘋果
</label>
<label>
<input type="checkbox">蘋果
</label>
</fieldset>
<!--單選-->
<label>
<input type="radio" name="rl" id="man">男
</label>
<fieldset data-role="controlgroup" >
<label>
<input type="radio" name="rl" id="man">男
</label>
<label>
<input type="radio" name="rl" id="woman">女
</label>
</fieldset>
<!--可展開項 :默認展開內容data-collapsed="false",去掉展開邊框data-content-theme="false"-->
<div data-role="collapsible" data-collapsed="false">
<h4>Heading</h4>
<p>這是展開的內容</p>
</div>
<div data-role="collapsible" data-content-theme="false">
<h4>Heading</h4>
<p>這是展開的內容</p>
</div>
<!--展開列表項-->
<div data-role="collapsible" data-content-theme="false">
<h1>系列</h1>
<ul data-role="listview">
<li><a href="#">item1</a></li>
<li><a href="#">item2</a></li>
<li><a href="#">item3</a></li>
</ul>
</div>
|
<!--grid:兩列ui-grid-a,三列ui-grid-b.....,列ui-block-a,bar類型ui-bar-->
<div class="ui-grid-b">
<div class="ui-block-a">
<div class="ui-bar ui-bar-a">Hello A</div>
</div>
<div class="ui-block-b">
<div class="ui-bar ui-bar-a">Hello B</div>
</div>
<div class="ui-block-c">
<div class="ui-bar ui-bar-a">Hello C</div>
</div>
</div>
<!--第二行-->
<div class="ui-grid-b">
<div class="ui-block-a">
Hello A
<input type="button" data-theme="a" value="按鈕">
<input type="button" data-theme="b" value="按鈕">
<input type="button" data-theme="a" value="按鈕">
</div>
<div class="ui-block-b">
Hello B
<input type="button" data-theme="a" value="按鈕">
<input type="button" data-theme="a" value="按鈕">
</div>
<div class="ui-block-c">
<div class="ui-bar ui-bar-a">Hello C</div>
<input type="button" data-theme="a" value="按鈕">
<input type="button" data-theme="a" value="按鈕">
<input type="button" data-theme="a" value="按鈕">
</div>
</div>
<!--一列ui-grid-solo-->
<div class="ui-grid-solo">
<div class="ui-block-a">
<input type="button" value="按鈕">
</div>
</div>
<!--listview:data-role="listview",加個<a>標籤即可點擊效果。 過濾item data-filter="true" 可插入data-inset="true"-->
<ul data-role="listview" data-filter="true" data-inset="true">
<li><a href="#">A</a></li>
<li><a href="#">B</a></li>
<li><a href="#">C</a></li>
</ul>
<form class="ui-filterable">
<input id="autoinput" data-type="search">
</form>
<!-- 不顯示data-filter-reveal="true" 指向form data-input="#autoinput"-->
<ul data-role="listview" data-filter="true" data-filter-reveal="true" data-input="#autoinput" data-inset="true">
<li><a href="#">A</a></li>
<li><a href="#">B</a></li>
<li><a href="#">C</a></li>
<li><a href="#">B</a></li>
<li><a href="#">D</a></li>
<li><a href="#">A</a></li>
<li><a href="#">E</a></li>
</ul>
<!--自動分配器data-autoviders="true"-->
<ul data-role="listview" data-autodividers="true" data-filter="true" data-inset="true">
<li><a href="#">A</a></li>
<li><a href="#">A</a></li>
<li><a href="#">addd</a></li>
<li><a href="#">B</a></li>
<li><a href="#">Big ddd </a></li>
<li><a href="#">bbb </a></li>
<li><a href="#">C</a></li>
<li><a href="#">Code</a></li>
<li><a href="#">D</a></li>
<li><a href="#">E</a></li>
</ul>
|
<!--導航:navbar-->
<div data-role="navbar">
<ul>
<li><a href="#" class="ui-btn-active">A</a></li>
<li><a href="#">B</a></li>
<li><a href="#">C</a></li>
</ul>
</div>
<!--彈出窗口:popup,a屬性data-rel="popup",div屬性data-role="popup"-->
<a href="#pp" data-rel="popup" class="ui-btn">彈出窗口</a>
<div data-role="popup" id="pp">
<p>這是一個彈出窗口</p>
</div>
<!--顯示位置屏幕前data-position-to="window"-->
<a href="#pop" data-rel="popup" data-position-to="window" data-transition ="fade">
<img src="images/logo11.png" class="pupphoto" style="width: 20%">
</a>
<div data-role="popup" id="pop">
<!--a標籤是一個刪除圖標,點擊返回-->
<a href="#" data-rel="back" class="ui-btn ui-shadow ui-corner-all ui-icon-delete ui-btn-icon-notext ui-btn-right"></a>
<img src="images/logo11.png" class="popphoto" style="height: 500px">
</div>
|
data-theme="b"//a或b主題
<!--下拉選擇-->
<div class="ui-field-contain">
<select name="select-native-1" id="select-native-1" data-iconpos="left">
<option value="1">這是第1個</option>
<!--不能被選中-->
<option value="2" disabled="disabled">這是第2個</option>
<option value="3">這是第3個</option>
<option value="4">這是第4個</option>
</select>
</div>
|
<script>
$(document).on("pageinit",function(){
// alert("hello");
$(".p").on("tap",function(){//點擊隱藏
$(this).hide();
});
$(".btn").on("taphold",function(){//長按隱藏
$(this).hide();
});
$(".p1").on("swipe",function(){//滑動隱藏
$(this).hide();
});
$(".btn1").on("swiperight",function(){//右滑動隱藏
$(this).hide();
});
$(document).on("scrollstop",function(){//長按隱藏
alert("停止滑動了");
});
});
|
/*創建舞臺,文本,圖形*/
var stage=new createjs.Stage("gameView");
var gameView=new createjs.Container();//創建容器
stage.addChild(gameView);
var text=new createjs.Text("Hello easeljs","26px Arial","#777");
//stage.alpha=0.5;//半透明
//stage.x=100;//移動舞臺裏的內容
//stage.y=100;
//stage.scaleX=2;//縮放舞臺裏內容
//stage.scaleY=0.5;
var Rect=new createjs.Shape();//創建圖形
Rect.graphics.beginFill("#FF0000");//設置顏色
Rect.graphics.drawRect(50,50,50,50);//參數1:x,參數2:y,參數3:寬度,參數4:高度。
gameView.addChild(text);//添加到容器中
gameView.addChild(Rect);
/*引入js,添加container*/
var c =new ChildContainer();
c.x=200;//移動
c.y=200;
gameView.addChild(c);
stage.update();//刷新
|
/*對圓的封裝*/
function Cricle(){
createjs.Shape.call(this);//。調用不加()
this.setCircleType=function(type){
this._cricleType=type;
switch (type){
case Cricle.TYPE_RED:
this.setColor("#ff0000");
break;
case Cricle.TYPE_GREEN:
this.setColor("#00ff00");
break;
}
};
this.setColor=function (color){
this.graphics.beginFill(color);
this.graphics.drawCircle(0,0,50);
this.graphics.endFill();
}
this.setCircleType(Cricle.TYPE_RED);//設置默認顏色
}
Cricle.prototype=new createjs.Shape();//設置圖形的入口
Cricle.TYPE_RED=1;//設置常量
Cricl
|
Rect.addEventListener("click",function(e){//點擊獲取位置
alert("X=:"+ e.localX+", Y=:"+ e.localY);
});
Ellipse.addEventListener("dblclick",function(){//點擊獲取位置
alert("雙擊了事件");
});
/*Ticker:類似計時器,實時更新舞臺*/
createjs.Ticker.setFPS(20);//設置 幀數/s
createjs.Ticker.addEventListener("tick",handlerTick);
var speedX=10;
function handlerTick(){
/*通過限制增加的範圍實現,左右不斷移動*/
if(Rect.x<=0){//左邊
speedX=Math.abs(speedX);
}
if(Rect.x>=350){//右邊-方塊寬
speedX=-Math.abs(speedX);
}
Rect.x+=speedX;
stage.update();
}
|
/*1,創建文本*/
var text=new createjs.Text("Hello easeljs","26px Arial","#777");
text.x=50;
text.y=50;
text.rotation=10;
var rect=new createjs.Shape();
rect.x=text.x;
rect.y=text.y;
rect.rotation=text.rotation;
stage.addChildAt(rect,0);//添加帶有子元素的
createjs.Ticker.setFPS(10);
createjs.Ticker.addEventListener("tick",handlerTicker);
function handlerTicker(e){
count++;
text.text="Hello easeljs"+count+"!"
//每次text增加寬度,重繪rect
rect.graphics.clear().beginFill("#F00").drawRect(-10,-10,text.getMeasuredWidth()+10,50);
stage.update(e);
}
|
var bitmap=new createjs.Bitmap("images/e1.png");
bitmap.x=300;
bitmap.y=300;
gameView.addChild(bitmap);
|