在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
一、HTML5 中的一些有趣的新特性: 用于绘画的 canvas 元素 Ogg = 带有 Theora 视频编码和 Vorbis 音频编码的 Ogg 文件
复制代码 代码如下:<!DOCTYPE html PUBLIC "-//WC//DTD XHTML . Transitional//EN" "http://www.w.org/TR/xhtml/DTD/xhtml-transitional.dtd"> <html xmlns="http://www.w.org//xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-" /> <title>视频</title> </head> <body> <video src=". HTML音频视频-编解码工具.mp" controls="controls" width="px" height="px"></video> </body> </html> 效果:
<小知识:在JS函数里输入console.log("hello");表示在浏览器控制台输出hello,若控制台可以输出hello,则表示函数是可以调用的。 复制代码 代码如下:<!DOCTYPE html PUBLIC "-//WC//DTD XHTML . Transitional//EN" "http://www.w.org/TR/xhtml/DTD/xhtml-transitional.dtd"> <html xmlns="http://www.w.org//xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-" /> <title>视频</title> </head> <body> <video id="video" src=". HTML音频视频-编解码工具.mp" width="px" height="px"></video> <button onclick="clickA()">播放/暂停</button> <button onclick="clickBig()">放大</button> <button onclick="clickSmall()">缩小</button> <script><!--若此JS部分写在<head></head>中,视频将播放错误--> var a = document.getElementById("video"); function clickA() { if(a.paused) a.play(); else a.pause(); } function clickBig() { a.width = ; a.height = ; } function clickSmall() { a.width = ; <!--此处不能写px,否则会出错,可以写成a.width = +"px";--> a.height = ; } </script> </body> </html> 效果:
复制代码 代码如下:<!DOCTYPE html PUBLIC "-//WC//DTD XHTML . Transitional//EN" "http://www.w.org/TR/xhtml/DTD/xhtml-transitional.dtd"> <html xmlns="http://www.w.org//xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-" /> <title>画布</title> <script type="text/javascript"> function cnvs_getCoordinates(e) { x=e.clientX; <!--clientX 事件属性返回当事件被触发时鼠标指针向对于浏览器页面(或客户区)的水平坐标--> y=e.clientY; document.getElementById("xycoordinates").innerHTML="Coordinates: (" + x + "," + y + ")"; } function cnvs_clearCoordinates() { document.getElementById("xycoordinates").innerHTML=""; } </script> </head> <body style="margin:px;"> <p>把鼠标悬停在下面的矩形上可以看到坐标:</p> <div id="coordiv" style="float:left;width:px;height:px;border:px solid #ccc" onmousemove="cnvs_getCoordinates(event)" onmouseout="cnvs_clearCoordinates()"></div> <div id="xycoordinates"></div> </body> </html> 知识点:
复制代码 代码如下:<!DOCTYPE html PUBLIC "-//WC//DTD XHTML . Transitional//EN" "http://www.w.org/TR/xhtml/DTD/xhtml-transitional.dtd"> <html xmlns="http://www.w.org//xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-" /> <title>画布</title> </head> <body> <canvas id="myCanvas" width="" height="" style="border:px solid #ccc;"> Your browser does not support the canvas element. </canvas> <script type="text/javascript"> var c=document.getElementById("myCanvas"); var cxt=c.getContext("d"); cxt.moveTo(,); cxt.lineTo(,); cxt.lineTo(,); cxt.stroke(); </script> </body> </html> 知识点:
复制代码 代码如下:<!DOCTYPE html PUBLIC "-//WC//DTD XHTML . Transitional//EN" "http://www.w.org/TR/xhtml/DTD/xhtml-transitional.dtd"> <html xmlns="http://www.w.org//xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-" /> <title>画布</title> </head> <body> <canvas id="myCanvas" width="" height="" style="border:px solid #ccc;"></canvas> <!--不能放在JS代码之后,否则效果出不来--> <script type="text/javascript"> var c=document.getElementById("myCanvas"); var cxt=c.getContext("d"); cxt.fillStyle="#FF"; cxt.beginPath(); cxt.arc(,,,,Math.PI*,true); cxt.closePath(); cxt.fill(); </script> </body> </html> 效果:
复制代码 代码如下:<!DOCTYPE html PUBLIC "-//WC//DTD XHTML . Transitional//EN" "http://www.w.org/TR/xhtml/DTD/xhtml-transitional.dtd"> <html xmlns="http://www.w.org//xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-" /> <title>画布</title> </head> <body> <canvas id="myCanvas" width="" height="" style="border:px solid #ccc;"></canvas> <script type="text/javascript"> var c=document.getElementById("myCanvas"); var cxt=c.getContext("d"); var grd=cxt.createLinearGradient(,,,); grd.addColorStop(,"#FF"); grd.addColorStop(,"#FF"); cxt.fillStyle=grd; cxt.fillRect(,,,); </script> </body> </html> 效果:
复制代码 代码如下:<!DOCTYPE html PUBLIC "-//WC//DTD XHTML . Transitional//EN" "http://www.w.org/TR/xhtml/DTD/xhtml-transitional.dtd"> <html xmlns="http://www.w.org//xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-" /> <title>画布</title> </head> <body> <canvas id="myCanvas" width="" height="" style="border:px solid #ccc;"></canvas> <script type="text/javascript"> var c=document.getElementById("myCanvas"); var cxt=c.getContext("d"); var img=new Image(); img.src=".png"; cxt.drawImage(img,,); </script> </body> </html> |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论