gpt4 book ai didi

html - 在嵌入式视频上叠加透明背景

转载 作者:太空狗 更新时间:2023-10-29 14:00:37 24 4
gpt4 key购买 nike

我有一个视频,我已将其嵌入到全 Angular div 面板中。我试图在它上面叠加一个渐变,但我无法让它工作。我试过调整 z-index,将视频包装在另一个 div 中,并且 - 如下所示 - 添加覆盖类,但我一定遗漏了一些明显的东西。

无论我尝试什么,视频都会跳回到其他面板的顶部(最终落后于它)。

非常感谢您的帮助!

                <div class="videoContainer hide-for-small-only">
<div class="overlay"></div>
<video autoplay loop muted>
<source src="<?=URL?>public/videos/vid.mp4" type="video/mp4">
<source src="<?=URL?>public/videos/vid.webm" type="video/webm">
</video>
</div>

我的 CSS 是:

.videoContainer 
{

position: absolute;
width: 100%;
height: 100%;
//padding: 20px;
border-radius: 5px;

background-attachment: scroll;
overflow: hidden;
}

.videoContainer video
{
min-width: 100%;
min-height: 100%;
}
.videoContainer overlay {
background: black;
opacity: 0.5;
position: absolute;
z-index: 1;
text-align: center;
margin: 0%;
}

最佳答案

这是一个fiddle

我在演示中使用了绿色覆盖层。

CSS

.videoContainer {
position: relative;
width: 100%;
height: 100%;
//padding: 20px;
border-radius: 5px;
background-attachment: scroll;
overflow: hidden;
}
.videoContainer video {
min-width: 100%;
min-height: 100%;
position: relative;
z-index: 1;
}
.videoContainer .overlay {
height: 100%;
width: 100%;
position: absolute;
top: 0px;
left: 0px;
z-index: 2;
background: green;
opacity: 0.5;
}

关于html - 在嵌入式视频上叠加透明背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31428660/

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