css - 100% 的 html5 视频在没有 DOCTYPE 的情况下工作 (videojs)

标签 css html html5-video video.js

以下 HTML 不会产生 100% 的视频大小。如果我删除 <!DOCTYPE html>一切正常。

<!DOCTYPE html>
<html>
<head>
    <link href="video-js/video-js.css" rel="stylesheet">
    <script src="video-js/video.js"></script>
    <script>videojs.options.flash.swf = "video-js/video-js.swf"</script>
</head>

<body>
    <video id="myVideo" class="video-js vjs-default-skin video-container" width="100%" height="100%" controls autoplay preload="auto" poster="poster.jpg" data-setup="{}">
      <source src="test.mp4" type='video/mp4'/>
    </video>
</body>
</html>

建议为每个 HTML 页面定义一个 DOCTYPE。我可以保留它,但它不适用于 IE 版本 < 10。

我搜索了那个问题并找到了 this solutions但它们不适用于我的 DOCTYPE。

我是否错过了一些基本的东西?

我正在使用 videojs 4.0.3。

编辑:根据提示和这个问题的答案,我在这里提供了一个解决方案:

<div class="video-container">
    <video id="myVideo" class="video-js vjs-default-skin" controls autoplay preload="auto" poster="poster.jpg" data-setup="{}">
      <source src="video.mp4" type='video/mp4'/>
    </video>
</div>

和相应的CSS:

body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
}

.video-container {
  width: 100%;
  height: 100%;
}

.video-js {
  width: 100% !important;
  height: 100% !important;
  position: absolute !important;
  z-index: 1;
}

最佳答案

我不知道这是为什么的确切细节,但我看到 html 文档类型(正确的 HTML5 文档类型)默认情况下 html 页面的宽度/高度不是 100%。如果您在 css 的某处添加以下内容,应该可以解决您的问题。

html, body { width: 100%; height: 100% }

示例:http://jsbin.com/uyelud/1/edit

关于css - 100% 的 html5 视频在没有 DOCTYPE 的情况下工作 (videojs),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16922126/

相关文章:

HTML - 占剩余页面高度 100% 的 div

css - 如何引用 SVG Sprite 符号内的内部渐变定义?

html - 媒体查询隐藏桌面视口(viewport)

css - 图片和 HTML5 视频不会有相同的高度

css - IE8 td 边框不一致

javascript - DIV 中的长 UL 列表,自动滚动到 LI 元素

html - 如何有一个歪的div?

javascript - 使用 JQuery 隐藏动态创建的 HTML 元素

javascript - 如何测试浏览器是否可以播放avi格式的视频?

javascript - 尽管 HTML5 可以完成我需要的一切,为什么我还需要视频播放器引擎?