在 HTML 中设置元素宽度


在 HTML 中,使用宽度属性来设置元素的宽度。可以对下列元素使用该属性:<canvas>、<embed>、<img>、<input>、<video> 等。

示例

尝试运行以下代码来在 HTML 中实现宽度属性 −

 实时演示

<!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 次浏览

开启你的职业生涯

完成课程,获得认证

开始学习
广告
© . All rights reserved.