在 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.