使用 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.