gpt4 book ai didi

javascript - 视频背景在 Safari 上无法正常播放

转载 作者:太空宇宙 更新时间:2023-11-04 02:53:35 25 4
gpt4 key购买 nike

视频背景在 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;
}

最佳答案

您需要将转换的 vendor 前缀版本添加到您的 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;
}

关于javascript - 视频背景在 Safari 上无法正常播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32590353/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com