【发布时间】:2016-10-24 08:10:48
【问题描述】:
大家好! 我有一个关于背景视频的问题,我将它附加到整个页面,但只需要将它嵌入到顶部。谁能告诉我有什么问题? 非常感谢! HTML:
<video autoplay loop poster="video-bg.jpg" id="bgvid">
<source src="video-bg.webm" type="video/webm">
<source src="video-bg.mp4" type="video/mp4">
</video>
CSS:
video#bgvid {
position: fixed;
top: 50%;
left: 50%;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
z-index: -100;
-ms-transform: translateX(-50%) translateY(-50%);
-moz-transform: translateX(-50%) translateY(-50%);
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
background: url(video-bg.jpg) no-repeat;
background-size: cover;
}
@media screen and (max-device-width: 800px) {
html {
background: url(video-bg.jpg) #000 no-repeat center center fixed;
}
#bgvid {
display: none;
}
}
【问题讨论】:
-
需要在顶部嵌入方式吗?
标签: css html html5-video