【问题标题】:Video Background not playing properly on Safari视频背景在 Safari 上无法正常播放
【发布时间】:2015-09-15 23:49:44
【问题描述】:

视频背景无法在 Safari 上正常播放。它显示在屏幕的右下角,看起来不太好。但这在 Chrome 上效果很好。

这里是link

这是 HTML 代码:

<video autoplay  poster="" id="bgvid" loop>
  <!-- WCAG general accessibility recommendation is that media such as background video play through only once. Loop turned on for the purposes of illustration; if removed, the end of the video will fade in the same way created by pressing the "Pause" button  -->
<source src="http://devjentri.com/wp-content/uploads/2015/09/deW_vid_final_.webm" type="video/webm">
<source src="http://devjentri.com/wp-content/uploads/2015/09/deW-vid-final-.mov" type="video/mp4">
</video>

CSS 代码:

video { 
    position: fixed;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    z-index: -100;
    transform: translateX(-50%) translateY(-50%);
    background-size: cover;
    transition: 1s opacity;
}

【问题讨论】:

  • 哪个版本的 Safari 和在什么操作系统上?我什至无法在 Chrome 中加载链接。

标签: javascript html css safari


【解决方案1】:

您需要将转换的供应商前缀版本添加到您的 CSS 规则中:

-webkit-transform: translateX(-50%) translateY(-50%);

完整的规则应该是这样的:

video { 
    position: fixed;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    z-index: -100;
    -webkit-transform: translateX(-50%) translateY(-50%);
    transform: translateX(-50%) translateY(-50%);
    background-size: cover;
    transition: 1s opacity;
}

【讨论】:

    猜你喜欢
    • 2020-04-07
    • 2022-11-02
    • 1970-01-01
    • 2021-10-08
    • 2022-01-19
    • 2020-02-10
    • 1970-01-01
    • 1970-01-01
    • 2020-02-24
    相关资源
    最近更新 更多