在 HTML 中设置元素宽度


在 HTML 中使用 width 属性设置元素的宽度。可以使用此属性和以下元素:<canvas>、<embed>、<img>、<input>、<video> 等等。

示例

您可以尝试运行以下代码以在 HTML 中实现width 属性:-

 在线演示

<!DOCTYPE HTML>
<html>
   <body>

      <video width="300" height="200" controls autoplay>
         <source src = "/html5/foo.ogg" type = "video/ogg" />
         <source src = "/html5/foo.mp4" type = "video/mp4" />
         Your browser does not support the video element.
      </video>

   </body>
</html>

输出

更新于: 2020 年 6 月 24 日

232 次观看

助力您的职业

完成课程取得认证

开始学习
广告