css 位置固定且背景附件固定在 chrome 上的 HTML 视频
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22330108/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTML video with css position fixed and background-attachment fixed on chrome
提问by Mathew
I have a video with position fixed and a couple of div with background-attachment fixed. Everything works fine in firefox and IE but with chrome, the background images don't display well.
我有一个位置固定的视频和几个固定背景附件的 div。在 Firefox 和 IE 中一切正常,但使用 chrome,背景图像显示效果不佳。
HTML:
HTML:
<video class="sleep-video" autoplay>
<source src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
<source src="http://www.w3schools.com/html/mov_bbb.ogg" type="video/ogg">
</video>
<div class="section one"></div>
<div class="section two"></div>
<div class="section three"></div>
CSS:
CSS:
body, html {
padding: 0;
margin:0;
height: 100%;
}
.section {
width: 100%;
height: 100%;
background-attachment: fixed;
background-size: 100% 100%;
position: relative;
background-color: white;
z-index: 2;
}
.section.one,
.section.three {
background-image: url(http://www.maximumpc.com/files/u160391/chrome_0.png);
}
.section.two {
background: none;
}
.sleep-video {
left: 0;
top: 0;
position: fixed;
width: 100%;
z-index: 1;
}
I absolutely need to have background-attachment fixed for the images because my site use parallax effects. Currently, the workaround that I use is to hide the video when I don't need it but it's far from ideal.
我绝对需要为图像修复背景附件,因为我的网站使用视差效果。目前,我使用的解决方法是在不需要时隐藏视频,但这远非理想。