html - 适合对象 : cover - is not working with video tags without border-radius

标签 html css html5-video

我面临一个问题,我无法使 object-fit: cover; 使用视频标签,因为它覆盖在父容器之外,即使我使用 object-fit:封面;

只有一种解决方案有效:添加一个具有某些值的边界半径,例如:

边框半径:10px; 到视频标签 css。

工作示例: https://codepen.io/anon/pen/qmrvLB 注释掉 border-radius: 10px; 行,看看我的问题是什么。

最佳答案

如果使用 border-radius: 1px;(没有人会看到那个半径)感觉太古怪,请使用 wrapper

body {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wrapper {
  width: 50%;
  height: 50px;
  overflow: hidden;
}

video {
  object-fit: cover;
  width: 100%;
  height: 100%;
}
<div class="wrapper">
  <video poster="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/polina.jpg" id="bgvid" playsinline autoplay muted loop>
<source src="http://thenewcode.com/assets/videos/polina.webm" type="video/webm">
<source src="http://thenewcode.com/assets/videos/polina.mp4" type="video/mp4">
  </video>
</div>

关于html - 适合对象 : cover - is not working with video tags without border-radius,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43693558/

相关文章:

css - 居中的 DIV,两边有不同的背景

css - Google Web 字体不适用于 IE < 9

jquery - 在html5视频结束时执行函数

html - 第一个 child CSS 不工作

php - 从 MySQL 创建社区成员列表

jquery - 在 jQuery 中联系表单 7 调用提交事件

javascript - 在 HTML5 视频上启用 iPad Airplay

javascript - onMouseOver、超链接和 rel...帮助我 :(

css - 组织多个 CSS 代码的更好方法?

javascript - 如何使用收发器 API 初始化 WebRTC 调用,但仅在信令完成后才启用音频和视频?