为视频播放器使用 CSS max-width 响应式属性


你可以尝试运行以下代码,使用 max-width 属性来使你的视频播放器响应式——

示例

现场演示

<!DOCTYPE html>
<html>
   <head>
      <meta name = "viewport" content = "width=device-width, initial-scale = 1.0">
      <style>
         video {
            max-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 年 7 月 4 日

515 次浏览

开启你的职业生涯

完成课程后获得认证

开始
广告
© . All rights reserved.