使用 CSS width 属性实现响应式视频播放器

cssweb developmentfront end technology更新于 2024/8/26 0:44:17

要使您的视频播放器具有响应式,请使用 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>

相关文章


有用资源