html5橡皮擦
来源:学生作业帮助网 编辑:作业帮 时间:2024/09/24 06:29:52 字数作文
篇一:HTML5实现手势屏幕解锁
HTML5实现手势屏幕解锁
明月H5课程 效果展示
实现原理
利用HTML5的canvas,将解锁的圈圈划出,利用touch事件解锁这些圈圈,直接看代码。
function createCircle() {// 创建解锁点的坐标,根据canvas的大小来平均分配半径
var n = chooseType;// 画出n*n的矩阵
lastPoint = [];
arr = [];
restPoint = [];
r = ctx.canvas.width / (2 + 4 * n);// 公式计算 半径和canvas的大小有关
for (var i = 0 ; i < n ; i++) {
for (var j = 0 ; j < n ; j++) {
arr.push({
x: j * 4 * r + 3 * r,
y: i * 4 * r + 3 * r
});
restPoint.push({
x: j * 4 * r + 3 * r,
y: i * 4 * r + 3 * r
});
}
}
//return arr;
}
复制代码
canvas里的圆圈画好之后可以进行事件绑定
function bindEvent() {
can.addEventListener("touchstart", function (e) {
var po = getPosition(e);
console.log(po);
for (var i = 0 ; i < arr.length ; i++) {
if (Math.abs(po.x - arr[i].x) < r && Math.abs(po.y - arr[i].y) < r) { // 用来判断起始点是否在圈圈内部
touchFlag = true;
drawPoint(arr[i].x,arr[i].y);
lastPoint.push(arr[i]);
restPoint.splice(i,1);
break;
}
}
}, false);
can.addEventListener("touchmove", function (e) {
if (touchFlag) {
update(getPosition(e));
}
}, false);
can.addEventListener("touchend", function (e) {
if (touchFlag) {
touchFlag = false;
storePass(lastPoint);
setTimeout(function(){
init();
}, 300);
}
}, false);
}
复制代码
接着到了最关键的步骤绘制解锁路径逻辑,通过touchmove事件的不断触发,调用canvas的moveTo方法和lineTo方法来画出折现,同时判断是否达到我们所画的圈圈里面,其中lastPoint保存正确的圈圈路径,restPoint保存全部圈圈去除正确路径之后剩余的。 Update方法:
function update(po) {// 核心变换方法在touchmove时候调用
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
for (var i = 0 ; i < arr.length ; i++) { // 每帧先把面板画出来
drawCle(arr[i].x, arr[i].y);
}
drawPoint(lastPoint);// 每帧花轨迹
drawLine(po , lastPoint);// 每帧画圆心
for (var i = 0 ; i < restPoint.length ; i++) {
if (Math.abs(po.x - restPoint[i].x) < r && Math.abs(po.y - restPoint[i].y) < r) { drawPoint(restPoint[i].x, restPoint[i].y);
lastPoint.push(restPoint[i]);
restPoint.splice(i, 1);
break;
}
}
}
复制代码
最后就是收尾工作,把路径里面的lastPoint保存的数组变成密码存在localstorage里面,之后就用来处理解锁验证逻辑了。
function storePass(psw) {// touchend结束之后对密码和状态的处理
if (pswObj.step == 1) {
if (checkPass(pswObj.fpassword, psw)) {
pswObj.step = 2;
pswObj.spassword = psw;
document.getElementById('title').innerHTML = '密码保存成功';
drawStatusPoint('#2CFF26');
window.localStorage.setItem('passwordx', JSON.stringify(pswObj.spassword)); window.localStorage.setItem('chooseType', chooseType);
} else {
document.getElementById('title').innerHTML = '两次不一致,重新输入'; drawStatusPoint('red');
delete pswObj.step;
}
} else if (pswObj.step == 2) {
if (checkPass(pswObj.spassword, psw)) {
document.getElementById('title').innerHTML = '解锁成功';
drawStatusPoint('#2CFF26');
} else {
drawStatusPoint('red');
document.getElementById('title').innerHTML = '解锁失败';
}
} else {
pswObj.step = 1;
pswObj.fpassword = psw;
document.getElementById('title').innerHTML = '再次输入';
}
}
复制代码
篇二:基于HTML5 Canvas的画图板设计与实现
摘 要
Web2.0带来的丰富互联网技术让所有人都享受到了技术发展和体验进步的乐趣。而作为下一代互联网标准,HTML5自然也是备受期待和瞩目。HTML5是近十年来Web开发标准巨大的飞跃。和以前的版本不同,HTML5并非仅仅用来表示Web内容,它的新使命是将Web带入一个成熟的应用平台,在HTML5平台上,视频、音频、图象、动画,以及同电脑的交互都被标准化。现阶段对于HTML5技术的研发和开发工作主要集中在技术草案的确立与新互联网应用的开发上,而随着互联网的发展,HTML标准也在不断变化,HTML标准已经走过第4代了,因为它能够用简单的标签元素,代替属性能实现之前需要用很多复杂JavaScript代码才能有实现的功能,HTML5越来越受到欢迎。
HTML5带来很多令人激动的新特性,这在之前的HTML中是不可见到的。其中一个最值得提及的特性就是用于绘画的 HTML Canvas,可以对2D或位图进行动态、脚本的渲染。本文详细分析了HTML5技术的简介和发展前景,并深入探讨了HTML5引入的核心标签Canvas元素,介绍了Canvas可以实现的主要功能,在此基础上实现了部分类似Windows画图板的功能,包括铅笔、图章仿制、画直线、圆、矩形、橡皮擦、背景图、取色板、插入文字等功能,在实现过程中也利用了最新的CSS3技术,最后再次总结了这次毕设的经验和对未来的展望。
本文针对其引入的Canvas绘图元素进行了深入的研究,此元素可以替代画图作为动画渲染的工具,效率与安全性更高,开发更便捷,必将是以后的动画,游戏等应用首选的开发方式,前景非常好。
【关键词】Web2.0 HTML5 CSS3 Canvas
ABSTRACT
Web2.0 brings a wealth of Internet technology for all to enjoy the fun of technology development and experience progress. As a next-generation Internet standard, HTML5 is naturally highly anticipated and attention. HTML5 is a huge leap over the past decade Web development standards. Unlike the previous version,HTML5 is not just used to represent Web content, its new mission is the Web into a full-fledged application platform, HTML5 platform, video, audio, image, animation, and interaction with the computer be standardized. At this stage for the HTML5 technology and development work focused on the establishment of the draft technology and new Internet application development, HTML standards are changing with the development of the Internet, HTML standard has gone through four generations, because it simple label elements, instead of before the property can be realized with a lot of complex JavaScript code in order to achieve the functions, HTML5 has been more popular.
HTML5 brings a lot of exciting new features. This is not seen in the previous HTML. One of the most worth mentioning the characteristics is HTML Canvas for painting, 2D or bitmap rendering of dynamic script. I detailed analysis the HTML5 technology introduction and development prospects, a deeper look into the core of the introduction of HTML5 tag Canvas element, the Canvas can be achieved, based on the a similar Windows drawing board, including pencil, stamp imitation, draw a straight line, circle, rectangle, eraser, background image, take a swatch in the realization of the process also takes advantage of the latest CSS3 techniques and, finally, this complete set up experience and vision for the future.
This paper introduces the Canvas drawing elements which conducted research, this element can replace the drawing as a tool for animation rendering, higher efficiency and security, the development of more convenient, be the future animation, games and other application development method of choice , the outlook is very good.
【Key words】WEB2.0 HTML5 CSS3 Canvas
目 录
前 言 ....................................................................................................................................................... 1
第一章 关于HTML5和画图板 ..................................................................................................... 2
第一节 HTML5简介 ....................................................................................................................... 2
第二节 HTML5特性 ....................................................................................................................... 2
第三节 HTML5国内外发展现状 ................................................................................................ 3
第四节 画图工具 .............................................................................................................................. 4
第二章 相关技术简介 ....................................................................................................................... 5
第一节 Canvas元素简介................................................................................................................ 5
第二节 第一个Canvas程序的实现 ............................................................................................ 5
第三节 JavaScript及jQuery简介 ................................................................................................ 7
第四节 CSS3简介 ............................................................................................................................ 9
第五节 开发工具DreamWeaver介绍....................................................................................... 12
第六节 调试工具Firefox及Firebug简介 .............................................................................. 13
第三章 功能设计 .............................................................................................................................. 16
第一节 需求设计 ............................................................................................................................ 16
第二节 基本原理 ............................................................................................................................ 17
第三节 布局及界面设计 .............................................................................................................. 19
第四节 JavaScript设计 ................................................................................................................. 20
第四章 功能的实现 ......................................................................................................................... 21
第一节 简单功能的实现 .............................................................................................................. 21
第二节 前台显示实现 ................................................................................................................... 24
第三节 JavaScript画图实现 ........................................................................................................ 25
第四节 最终效果 ............................................................................................................................ 32
第五节 不足之处 ............................................................................................................................ 38
第五章 结束语 .................................................................................................................................. 39 致 谢 .................................................................................................................................................... 40 参考文献 ................................................................................................................................................ 41 附 录 .................................................................................................................................................... 42
前 言
随着互联网时代的高速发展,上网早已经成为人民日常生活中一个必不可少的部分,人们可以在网络上获取信息,甚至于在网络上完成日常的正常生活。看新闻,看电视,订餐等等。
HTML的上个版本早在1999年制定,随着21世纪网络的不断发展,已经不能适应当前的需求,于是HTML5营运而生了。HTML5是HTML下一个的主要修订版本,以期能在互联网应用迅速发展的时候,使网络标准达到符合当代的网络需求,现仍处于发展阶段。它希望能够减少浏览器对丰富性网络应用服务的插件的需要,并且提供更多能有效增强网络应用的标准集。
HTML5的出现再次告诉我们,我们的生活,日常办公,越来越有可能全在网页端实现了。如今很多人喜欢在电脑上绘图,画图版作为一个日常的生活工具,如今也能在我们网页端实现了。HTML5一个很有用实用的特性是用于绘画的Canvas元素,Canvas拥有许多绘制功能如画笔、矩形、圆形、字符以及图像处理的方法,他为人们在网页绘图及图像处理带来了方便。
第一章 关于HTML5和画图板
第一节 HTML5简介
HTML标准自1999年12月发布的HTML4.01后,后继的HTML5和其它标准被束之高阁,为了推动Web标准化运动的发展,一些公司联合起来,成立了一个叫做 Web Hypertext Application Technology Working Group (Web超文本应用技术工作组,WHATWG) 的组织。WHATWG 致力于 Web 表单和应用程序,而W3C(World Wide Web Consortium,万维网联盟) 专注于 XHTML 2.0。在 2006 年,双方决定进行合作,来创建一个新版本的 HTML。
HTML5 草案的前身名为 Web Applications 1.0,于2004年被WHATWG提出,于2007年被W3C接纳,并成立了新的 HTML 工作团队。
HTML5 的第一份正式草案已于2008年1月22日公布。HTML5 仍处于完善之中。然而,大部分现代浏览器已经具备了某些 HTML5 支持。
2012年12月17日,万维网联盟(W3C)正式宣布凝结了大量网络工作者心血的HTML5规范已经正式定稿。根据W3C的发言稿称:“HTML5是开放的Web网络平台的奠基石。”
支持HTML5的浏览器包括Firefox(火狐浏览器),IE9及其更高版本,Chrome(谷歌浏览器),Safari,Opera等;国内的傲游浏览器(Maxthon),以及基于IE所推出的360浏览器、搜狗浏览器、QQ浏览器、猎豹浏览器等国产浏览器同样具备支持HTML5的能力。
HTML5提供了一些新的元素和属性,例如
第二节 HTML5特性
一、取消了一些过时的HTML4标记
其中包括纯粹显示效果的标记,如和
新的HTML5 吸取了XHTML2 一些建议,包括一些用来改善文档结构的功能,比如,新的HTML 标签 header, footer, dialog, aside, figure 等的使用,将使内容创作者更加语义地创建文档,之前的开发者在实现这些功能时一般都是使用DIV。
二、将内容和展示分离
篇三:HTML5入门教程
HTML5教程
HTML 5 简介
HTML5 是下一代的HTML。
什么是HTML5?
HTML5 将成为HTML、XHTML 以及HTML DOM 的新标准。
HTML 的上一个版本诞生于1999 年。自从那以后,Web 世界已经经历了巨变。 HTML5 仍处于完善之中。然而,大部分现代浏览器已经具备了某些HTML5 支持。 HTML5 是如何起步的?
HTML5 是W3C 与WHATWG 合作的结果。
编者注:W3C 指World Wide Web Consortium,万维网联盟。
编者注:WHATWG 指Web Hypertext Application Technology Working Group。 WHATWG 致力于web 表单和应用程序,而W3C 专注于XHTML 2.0。在2006 年,双 方决定进行合作,来创建一个新版本的HTML。
为HTML5 建立的一些规则:
? 新特性应该基于HTML、CSS、DOM 以及JavaScript。
? 减少对外部插件的需求(比如Flash)
? 更优秀的错误处理
? 更多取代脚本的标记
? HTML5 应该独立于设备
? 开发进程应对公众透明
新特性
HTML5 中的一些有趣的新特性:
? 用于绘画的canvas 元素
? 用于媒介回放的video 和audio 元素
? 对本地离线存储的更好的支持
? 新的特殊内容元素,比如article、footer、header、nav、section
? 新的表单控件,比如calendar、date、time、email、url、search
浏览器支持
最新版本的Safari、Chrome、Firefox 以及Opera 支持某些HTML5 特性。Internet Explorer
9 将支持某些HTML5 特性。
HTML 5 视频
许多时髦的网站都提供视频。HTML5 提供了展示视频的标准。
Web 上的视频
直到现在,仍然不存在一项旨在网页上显示视频的标准。
今天,大多数视频是通过插件(比如Flash)来显示的。然而,并非所有浏览器都拥有同样 的插件。
HTML5 规定了一种通过video 元素来包含视频的标准方法。
视频格式
当前,video 元素支持两种视频格式:
Internet Explorer Firefox 3.5 Opera 10.5 Chrome 3.0 Safari 3.0
Ogg X X X
MPEG 4 X X
Ogg = 带有Thedora 视频编码和Vorbis 音频编码的Ogg 文件
MPEG4 = 带有H.264 视频编码和AAC 音频编码的MPEG 4 文件
如何工作
如需在HTML5 中显示视频,您所有需要的是:
control 属性供添加播放、暂停和音量控件。
包含宽度和高度属性也是不错的主意。
之间插入的内容是供不支持video 元素的浏览器显示的: 实例
上面的例子使用一个Ogg 文件,适用于Firefox、Opera 以及Chrome 浏览器。 要确保适用于Safari 浏览器,视频文件必须是MPEG4 类型。
video 元素允许多个source 元素。source 元素可以链接不同的视频文件。浏览器将使用第一个可识别的格式:
实例
Your browser does not support the video tag.
Internet Explorer
Internet Explorer 8 不支持video 元素。在IE 9 中,将提供对使用MPEG4 的video 元素 的支持。
(来自:WwW.smhaida.Com 海达 范文 网:html5橡皮擦)属性值描述
autoplay autoplay 如果出现该属性,则视频在就绪后马上播放。
controls controls 如果出现该属性,则向用户显示控件,比如播放按钮。 height pixels 设置视频播放器的高度。
loop loop 如果出现该属性,则当媒介文件完成播放后再次开始播放。
preload preload
如果出现该属性,则视频在页面加载时进行加载,并预备播放。
如果使用"autoplay",则忽略该属性。
src url 要播放的视频的URL。
width pixels 设置视频播放器的宽度。
HTML 5 音频
HTML5 提供了播放音频的标准。
Web 上的音频
直到现在,仍然不存在一项旨在网页上播放音频的标准。
今天,大多数音频是通过插件(比如Flash)来播放的。然而,并非所有浏览器都拥有同样 的插件。
HTML5 规定了一种通过audio 元素来包含音频的标准方法。
audio 元素能够播放声音文件或者音频流。
视频格式
当前,audio 元素支持三种音频格式:
Internet Explorer Firefox 3.5 Opera 10.5 Chrome 3.0 Safari 3.0
Ogg Vorbis X X X
MP3 X X
Wav X X X
如何工作
如需在HTML5 中播放音频,您所有需要的是:
control 属性供添加播放、暂停和音量控件。
之间插入的内容是供不支持audio 元素的浏览器显示的: 实例
Your browser does not support the audio tag.
上面的例子使用一个Ogg 文件,适用于Firefox、Opera 以及Chrome 浏览器(读者注:国产的很多浏览器也可以)。
要确保适用于Safari 浏览器,音频文件必须是MP3 或Wav 类型。
audio 元素允许多个source 元素。source 元素可以链接不同的音频文件。浏览器将使用第一个可识别的格式:
实例
篇四:HTML5的基础知识-个人整理
1.产生和发展
HTML5是用于取代1999年所制定的 HTML 4.01 和 XHTML 1.0 标准的 HTML [1](标准通用标记语言下的一个应用)标准版本;现在仍处于发展阶段,但大部分浏览器已经支持某些 HTML5 技术。HTML 5有两大特点:首先,强化了 Web 网页的表现性能。其次,追加了本地数据库等 Web 应用的功能。广义论及HTML5时,实际指的是包括HTML、CSS和JavaScript在内的一套技术组合。它希望能够减少浏览器对于需要插件的丰富性网络应用服务(plug-in-based rich internet application,RIA),如Adobe Flash、Microsoft Silverlight,与Oracle JavaFX的需求,并且提供更多能有效增强网络应用的标准集。
HTML5草案的前身名为 Web Applications 1.0,于2004年被WHATWG(Web Hypertext Application Technology Working Group (Web超文本应用技术工作组 -WHATWG))提出,于2007年被W3C接纳,并成立了新的 HTML 工作团队。
HTML 5 的第一份正式草案已于2008年1月22日公布[3]。HTML5 仍处于完善之中。然而,大部分现代浏览器已经具备了某些 HTML5 支持。
2013年5月6日, HTML 5.1正式草案公布。该规范定义了第五次重大版本,第一次要修订万维网的核心语言:超文本标记语言(HTML)。在这个版本中,新功能不断推出,以帮助Web应用程序的作者,努力提高新元素互操作性。
支持Html5的浏览器包括Firefox(火狐浏览器),IE9及其更高版本,Chrome(谷歌浏览器),Safari,Opera等;国内的傲游浏览器(Maxthon),以及基于IE或Chromium(Chrome的工程版或称实验版)所推出的360浏览器、搜狗浏览器、QQ浏览器、猎豹浏览器等国产浏览器同样具备支持HTML5的能力。
2.HTML5的特性
语义特性(Class:Semantic)
HTML5赋予网页更好的意义和结构。更加丰富的标签将随着对RDFa的,微数据与微格式等方面的支持,构建对程序、对用户都更有价值的数据驱动的Web。
本地存储特性(Class: OFFLINE & STORAGE)
基于HTML5开发的网页APP拥有更短的启动时间,更快的联网速度,这些全得益于HTML5 APP Cache,以及本地存储功能。Indexed DB(html5本地存储最重要的技术之一)和API说明文档。
设备兼容特性 (Class: DEVICE ACCESS)
从Geolocation功能的API文档公开以来,HTML5为网页应用开发者们提供了更多功能上的优化选择,带来了更多体验功能的优势。HTML5提供了前所未有的数据与应用接入开放接口。使外部应用可以直接与浏览器内部的数据直接相连,例如视频影音可直接与microphones及摄像头相联。
连接特性(Class: CONNECTIVITY)
更有效的连接工作效率,使得基于页面的实时聊天,更快速的网页游戏体验,更优化的在线交流得到了实现。HTML5拥有更有效的服务器推送技术,Server-Sent Event和WebSockets就是其中的两个特性,这两个特性能够帮助我们实现服务器将数据“推送”到客户端的功能。
网页多媒体特性(Class: MULTIMEDIA)
支持网页端的Audio、Video等多媒体功能,与网站自带的APPS,摄像头,影音功能相得益彰。
三维、图形及特效特性(Class: 3D, Graphics & Effects)
基于SVG、Canvas、WebGL及CSS3的3D功能,用户会惊叹于在浏览器中,所呈现的惊人视觉效果。
性能与集成特性(Class: Performance & Integration)
没有用户会永远等待你的Loading——HTML5会通过XMLHttpRequest2等技术,帮助您的Web应用和网站在多样化的环境中更快速的工作。
CSS3特性(Class: CSS3)
在不牺牲性能和语义结构的前提下,CSS3中提供了更多的风格和更强的效果。此外,较之以前的Web排版,Web的开放字体格式(WOFF)也提供了更高的灵活性和控制性。
3.HTML5的改变
HTML5提供了一些新的元素和属性,例如
1、取消了一些过时的HTML4标记
其中包括纯粹显示效果的标记,如和
2、将内容和展示分离
b 和i标签依然保留,但它们的意义已经和之前有所不同,这些标签的意义只是为了将一段文字标识出来,而不是为了为它们设置粗体或斜体式样。u,font,center,strike 这些标签则被完全去掉了。
3、一些全新的表单输入对象
包括日期,URL,Email 地址,其它的对象则增加了对非拉丁字符的支持。HTML5 还引入了微数据,这一使用机器可以识别的标签标注内容的方法,使语义Web 的处理更为简单。总的来说,这些与结构有关的改进使内容创建者可以创建更干净,更容易管理的网页,这样的网页对搜索引擎,对读屏软件等更为友好。
4、全新的,更合理的Tag
多媒体对象将不再全部绑定在object或 embed Tag 中,而是视频有视频的Tag,音频有音频的 Tag。
5、本地数据库
这个功能将内嵌一个本地的SQL 数据库,以加速交互式搜索,缓存以及索引功能。同时,那些离线Web 程序也将因此获益匪浅。不需要插件的丰富动画。
6、Canvas 对象
将给浏览器带来直接在上面绘制矢量图的能力,这意味着用户可以脱离Flash 和
Silverlight,直接在浏览器中显示图形或动画。
7、浏览器中的真正程序
将提供 API 实现浏览器内的编辑,拖放,以及各种图形用户界面的能力。内容修饰Tag 将被剔除,而使用CSS。
8、Html5取代Flash在移动设备的地位。
9、其突出的特点就是强化了web页的表现性,追加了本地数据库
4.HTML5的优点
网络标准
HTML5本身是由W3C推荐出来的,它的开发是通过谷歌、苹果,诺基亚、中国移动等几百家公司一起酝酿的技术,这个技术最大的好处在于它是一个公开的技术。换句话说,每一个公开的标准都可以根据W3C的资料库找寻根源。另一方面,W3C通过的HTML5标准也就意味着每一个浏览器或每一个平台都会去实现。
多设备跨平台
用HTML5的优点主要在于,这个技术可以进行跨平台的使用。比如你开发了一款HTML5的游戏,你可以很轻易地移植到UC的开放平台、Opera的游戏中心、Facebook应用平台,甚至可以通过封装的技术发放到App Store或Google Play上,所以它的跨平台非常强大,也是大多数人对HTML5有兴趣的主要原因。
自适应网页设计
很早就有人设想,能不能”一次设计,普遍适用”,让同一张网页自动适应不同大小的屏幕,根据屏幕宽度,自动调整布局(layout)?
2010年,Ethan Marcotte提出了”自适应网页设计“这个名词,指可以自动识别屏幕宽度、并做出相应调整的网页设计。
这就解决了传统的一种局面——网站为不同的设备提供不同的网页,比如专门提供一个mobile版本,或者iPhone / iPad版本。这样做固然保证了效果,但是比较麻烦,同时要维护好几个版本,而且如果一个网站有多个portal(入口),会大大增加架构设计的复杂度。
即时更新
游戏客户端每次都要更新,很麻烦。可是更新HTML5游戏就好像更新页面一样,是马上的、即时的更新。
总结概括HTML5有以下优点:
1、提高可用性和改进用户的友好体验;
2、有几个新的标签,这将有助于开发人员定义重要的内容; 3、可以给站点带来更多的多媒体元素(视频和音频); 4、可以很好的替代FLASH和Silverlight;
5、当涉及到网站的抓取和索引的时候,对于SEO很友好; 6、将被大量应用于移动应用程序和游戏。
5. 元素变化
新的解析顺序新的元素:section, video, progress, nav, meter, time, aside, canvasinput
元素的新属性:日期和时间,email, url。 新的通用属性:ping, charset, async 全域属性:id, tabindex, repeat。 移除元素:center, font, strike。
1.HTML5 中的一些有趣的新特性:
? ? ? ? ?
用于绘画的 canvas 元素
用于媒介回放的 video 和 audio 元素 对本地离线存储的更好的支持
新的特殊内容元素,比如 article、footer、header、nav、section 新的表单控件,比如 calendar、date、time、email、url、search
2.支持视频格式:
Ogg = 带有Theora视频编码和Vorbis音频编码的Ogg文件 MPEG4 = 带有 H.264 视频编码和 AAC 音频编码的 MPEG 4 文件 WebM = 带有 VP8 视频编码和Vorbis音频编码的WebM文件
测试代码:
control 属性供添加播放、暂停和音量控件。
包含宽度和高度属性也是不错的主意。
之间插入的内容是供不支持 video 元素的浏览器显示的: video 元素允许多个 source 元素。source 元素可以链接不同的视频文件。
Internet Explorer 8 不支持 video 元素。在 IE 9 中,将提供对使用 MPEG4 的 video 元素的支持。 Internet Explorer 8 不支持 audio 元素。在 IE 9 中,将提供对 audio 元素的支持。
3.HTML5新的Input类型
HTML5 拥有多个新的表单输入类型。这些新特性提供了更好的输入控制和验证。 包括:
? ? ? ? ? ? ?
email url number range
Date pickers (date, month, week, time, datetime, datetime-local) search color
浏览器支持
新的 input 属性:
? ? ? ? ? ?
autocomplete autofocus form
form overrides (formaction, formenctype, formmethod, formnovalidate, formtarget) height 和 width list
篇五:HTML5入门教学:简化的语法
文档类型Doctype:
文档类型的声明是一个HTML文档的第一行内容,它告诉浏览器这个页面是使用哪个版本的标记语言编写的。比如,HTML 4.01 Transitional 文档类型的声明是:
"/TR/xhtml1/DTD/xhtml1-transitional.dtd">
而HTML5中,你只需要:
字符编码
为了验证或显示一个HTML文档,程序必须选择一种字符编码。
字符编码告诉浏览器和验证程序应该使用哪种编码由比特流转换为字符。
下面是HTML 4.01指定UTF-8字符编码的例子:
在XHTML中:
而现在使用HTML5,编码类型的语法非常简单:
因此,最基本的HTML文档结构应该是:
Hello, World
在HTML5里:
〈script src=”code.js”>
HTML5为script标签添加了一个新的可选属性 “async”, 用来告诉浏览器异步加载代码,所以这段代码在页面继续加载的同时就会被执行。可以像下面这样使用:
或者:
标签
标签定义了文档与外部资源的联系,常用来引入CSS文件:
在HTML5K ,type属性跟