使用 CSS 寬度屬性為響應式影片播放器


要使您的影片播放器響應,請使用 width 屬性並將它設定為 100%

示例

現場演示

<!DOCTYPE html>
<html>
   <head>
      <meta name = "viewport" content="width=device-width, initial-scale=1.0">
         <style>
            video {
               width: 100%;
               height: auto;
            }
         </style>
   </head>
   <body>
      <video width = "300" controls autoplay>
         <source src = "/html5/foo.ogg" type = "video/ogg" />
         <source src = "/html5/foo.mp4" type = "video/mp4" />
      </video>
      <p>To check the effect, you need to resize the browser.</p>
   </body>
</html>

更新於: 2020-6-25

168 次瀏覽

開啟您的 職業生涯

完成課程,獲得認證

開始體驗
廣告
© . All rights reserved.