媒体元素

添加GIF

GIF代表“图形交换格式”,它是一种图像文件。 GIF和一般图像的区别是该文件包含许多图像。当显示在浏览器中时,图像将按顺序播放,类似于手翻书。

手翻书的GIF


新增影片

除了文字和图像,我们也可以增加视频。视频文件非常大,因此最好上传此视频于网路,例如YouTube。一旦上传到YouTube,我们将如何播放它?我们将使用一个称为iframe的特殊元素

iframe会显示其他网站的HTML。这就像一个窗口,你可以在你的网站中查看其他网站发生的情况。此过程称为嵌入(embedding)。例如,下面的视频是Benji Instragram的iframe:

View this post on Instagram

Push yourself to try new things! 🍉 I stick to the paleo diet most days (usually just the meat part) but on occasion I go for something crazy

A post shared by Benji Escobari Marquez (@benjimite_thegudboi) on

许多网站都提供iframe嵌入你的网站。例如,以下是查找YouTube视频的iframe代码的方法:

用iframe嵌入的列子

iframe 例子

复制以下代码:

<iframe width="560" height="315" src="https://www.youtube.com/embed/lQsqEBSGdyc" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen> </iframe>

将其黏贴到你的CodePen上,它将显示如下: