我正在尝试这样做:
<video id="test" loop autoplay>
<source src="assets/videos/h264.mp4" type="video/mp4">
<source src="assets/videos/h264.ogv" type="video/ogv">
<source src="assets/videos/h264.webm" type="video/webm">
</video>
CSS:
#test {
background:red;
width:100%;
height:100%;
position:fixed;
top:0;
left:0;
bottom:0;
right:0;
}
#test:after {
content: "";
background: #000;
position:fixed;
top:0;
left:0;
bottom:0;
right:0;
height:100%;
width:100%;
z-index:1;
}
为什么这不起作用?对我来说这样...... http://jsfiddle.net/13knrneg/
如果我用div替换视频标签,它可以100%工作。我在这里误解了什么?
答案 0 :(得分:0)
您应该将position: relative
用于视频块,将position: absolute
用于顶级伪层。
试试这个:
#test {
background: red;
width: 100%;
height: 100%;
position: relative;
display: block;
top: 0;
left: 0;
}
#test:after {
content: " ";
background: #000;
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
z-index: 1;
}