使用 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-06-25

168 次瀏覽

提升你的 職業生涯

完成課程,獲得認證

開始
廣告
© . All rights reserved.