HTML 图像/音视频

在 HTML 中,图像由 <img> 标签定义。

框架/图像标签

<img>    定义图像。
<map>    定义图像映射。
<canvas> 通过脚本(通常是 JavaScript)来绘制图形(比如图表和其他图像)。

<audio> 定义声音,比如音乐或其他音频流。
<video>    定义一个音频或者视频

实例

img

<img src="./images/img.jpeg"  width="200" height="200">

map

<img src="./images/img.jpeg" width="300" height="300" alt="Planets" usemap="#map">
<map name="map">
    <area shape="rect" coords="0,0,82,126" alt="Sun" href="2.html">
    <area shape="circle" coords="90,58,3" alt="Mercury" href="3.html">
    <area shape="circle" coords="124,58,8" alt="Venus" href="4.html">
</map>

canvas

<canvas id="myCanvas">你的浏览器不支持 HTML5 canvas 标签。</canvas>
<script>
var c=document.getElementById('myCanvas');
var ctx=c.getContext('2d');
ctx.fillStyle='#FF0000';
ctx.fillRect(0,0,100,100);
</script>

audio

<audio controls>
  <source src="horse.ogg" type="audio/ogg">
  <source src="horse.mp3" type="audio/mpeg">
  您的浏览器不支持 audio 元素。
</audio>
<video width="320" height="240" controls>
   <source src="./vedio/movie.mp4"  type="video/mp4">
   您的浏览器不支持 HTML5 video 标签。
</video>
posted @ 2021-06-21 08:05  胡勇健  阅读(83)  评论(0)    收藏  举报