【问题标题】:Trouble with Background Video- Safari Only- full width & full height背景视频问题 - 仅限 Safari - 全宽和全高
【发布时间】:2018-07-13 15:54:11
【问题描述】:

我只在 Safari 中看到了这个问题,Chrome 和 Firefox 都可以根据需要工作。似乎在 Safari 中它正在加载 .video-container > 视频高度:100% 但不是宽度:100%。有没有人遇到过这个问题或知道可能的解决方案?

网站构建网址:http://betterbrands.3rfocuslabs.com

我的风格:

video#bgvid {
background: url(images/home/bg-video.jpg) no-repeat;
background-size: cover;
}
.video-container {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
}
.video-container > video {
display: block;
position: fixed;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
z-index: 1;
}
@media screen and (max-aspect-ratio: 1920/1080) {
.video-container > video {
height: 100%;
}
}
@media screen and (min-aspect-ratio: 1920/1080) {
.video-container > video {
width: 100%;
}
}

我的代码:

<div class="video-container">
<video autoplay loop muted poster="<?php bloginfo('template_directory'); ?>/home/bg-video.jpg" id="bgvid">
<source src="<?php bloginfo('template_directory'); ?>/video/beer.mp4" type="video/mp4">
<source src="<?php bloginfo('template_directory'); ?>/video/beer.ogg" type="video/ogg">
<source src="<?php bloginfo('template_directory'); ?>/video/beer.webm" type="video/webm">
</video>
</div>

【问题讨论】:

  • 谁能指出一个可能的解决方案?

标签: css video safari background


【解决方案1】:

Safari 中存在视口单元 (https://bugs.webkit.org/show_bug.cgi?id=145614) 的错误。我想这是一个整体的错误。 似乎他们仅在今年 5 月才开始支持此功能。所以问题是可能的。 https://caniuse.com/#feat=viewport-units 检查已知问题和浏览器版本支持。

【讨论】:

  • 根据您链接的网站,似乎支持 Safari 11.1,但似乎没有任何已知问题。
  • 这是您提到的网站的屏幕截图:imgur.com/723ns8p。这是我遇到的问题的屏幕截图,显示我确实有 Safari 11.1:imgur.com/JcciLMb
猜你喜欢
  • 1970-01-01
  • 2020-03-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-24
相关资源
最近更新 更多